I'm attempting to process a dataframe one row at a time using iloc. I have a sorted frame read in from a Database:
branch animal owner
00177 cat Dave
00177 lion Peter
00177 dog Dave
00200 dog Mary
00200 dog Fred
00300 horse Doug
00400 cat Dave
I want to process each group of branch, so I thought if I compared each grpnum with the next one. like this:
for R in 0 to 7
while [df.iloc[[R],[0]] == df.iloc[[R+1],[0]]
do something
R = R + 1
Except I got this error:
ValueError: Can only compare identically-labeled DataFrame objects
Can I not process a DataFrame this way? How would one process a DataFrame row by row? I'm not tied to using a dataframe object, it was just convenient. This example shows Branch with 4 distinct values. There are actually over a thousand different values, and the same branch can contain up to thirty records and as few as one.