Delete the first three rows of a dataframe in pandas

df = df.iloc[n:]

n drops the first n rows.


I think a more explicit way of doing this is to use drop.

The syntax is:

df.drop(label)

And as pointed out by @tim and @ChaimG, this can be done in-place:

df.drop(label, inplace=True)

One way of implementing this could be:

df.drop(df.index[:3], inplace=True)

And another "in place" use:

df.drop(df.head(3).index, inplace=True)

A simple way is to use tail(-n) to remove the first n rows

df=df.tail(-3)


Use iloc:

df = df.iloc[3:]

will give you a new df without the first three rows.

Tags:

Python

Pandas