I am trying to loop over a DF to create a smaller DF, then performs other steps to that smaller DF. When completed, I want it to go further down the list to do those same actions until all of the rows in my original DF have been passed through the loop 100 rows at a time ( don't want tuples, or other data formats, i really need each to be in a DF).
i have what I thought was successful code below. start = 0 end = 99 for segment in df: segment = df.loc[start:end] start = start+100 end = end+100
This works for only the first 3 passes and then it stops. i added some code to help diagnose, but I still can't figure out why it's stopping.
print(len(df)
start = 0
end = 99
for segment in df:
segment = df.loc[start:end]
print(start,end)
start = start+100
end = end+100
results: 2265 0 99 100 199 200 299
Can anyone tell me why it's stopping at row 299? How can I get the loop to keep going through the whole DF (2265 rows)?
Thanks,