I have a Pandas DataFrame with the shape - (133, 6)
- and I am trying to use iloc to iterate down the frame then select and append chunks of data to a list.
I have a list of start positions:
start_positions = [6, 32, 58, 84, 110]
and the end positions are +7 rows, so I have tried this:
frames = []
for x in start_positions:
frames.append(df.iloc[start_positions[x] : start_positions[x]+7])
However is throwing:
IndexError: index 6 is out of bounds for axis 0 with size 5
Which I don’t quite understand as this works if I manually increment through start_positions
.