I have a scenario where i have to split the data frame which has n rows into multiple dataframe for every 35 rows. like lets say I have 100 rows in the dataframe. The first dataframe should have 1-35 rows the second dataframe should have 36-70 then third df should have the remaining datas.
Asked
Active
Viewed 3,975 times
1 Answers
2
You can just use a simple loop, and can access the dataframe slice via indexing:
for i in range(0, df.shape[0], 35):
print(df[i:i+35])
If you want, you can just store them in a list:
dfList = []
for i in range(0, df.shape[0], 35):
dfList.append(df[i:i+35])

ThePyGuy
- 17,779
- 5
- 18
- 45