如何合理分割数据帧长度?

时间:2018-11-06 18:35:47

标签: python python-3.x pandas

我有一个10800535 rows and 60 columns的df。

我想按索引拆分此数据帧,以便第一个数据帧具有顶部5400267行,第二个数据帧具有底部5400268。

两个数据框应具有相同的列。

1 个答案:

答案 0 :(得分:2)

locindex配合使用:

df1 = df.loc[:5400268,:] # 0 to 5400267 rows and all 60 columns
df2 = df.loc[5400268:,:] # 5400268 to last rows and all 60 columns