How To Split Dataframe Length Wise?
I have a df that is 10800535 rows and 60 columns. I want to split this dataframe by index so that first dataframe has top 5400267 rows and the second one has the bottom 5400268.
Solution 1:
Use loc
with index
as:
df1 = df.loc[:5400268,:] # 0 to 5400267 rows and all 60 columns
df2 = df.loc[5400268:,:] # 5400268 to last rows and all 60 columns
Post a Comment for "How To Split Dataframe Length Wise?"