I want to clear the first 9 rows of a dataframe in Pandas.
I have to drop all rows using:
df.drop([0,1,2,3,4,5,6,7,8])
Is there a more efficient way to do this? I have tried using a range:
df.drop([0:9])
but this does not help.
I want to clear the first 9 rows of a dataframe in Pandas.
I have to drop all rows using:
df.drop([0,1,2,3,4,5,6,7,8])
Is there a more efficient way to do this? I have tried using a range:
df.drop([0:9])
but this does not help.
The best way to do this is by indexing: df.drop(df.index[0:9])
. This example will drop the first ten rows.