1

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.

4o4o_Adv
  • 43
  • 6

1 Answers1

1

The best way to do this is by indexing: df.drop(df.index[0:9]). This example will drop the first ten rows.

medenzon
  • 24
  • 2