Home > Software engineering >  Delete second row of pandas dataframe
Delete second row of pandas dataframe

Time:10-31

I am trying to delete the second row of pandas dataframe but I was unable to do so.
Code used:


df1.drop([1,],axis=0, inplace=True)

Note: The second row is empty that's why I want it gone.

CodePudding user response:

Jaemimin's solution is likely better, but I think you could also slice the dataframe with

df1.loc[df1.index != 1]

Which for a dataframe like:

date  value
0      today      1
1  yesterday      2
2  yesterday      3

yields:

        date  value
0      today      1
2  yesterday      3

CodePudding user response:

This one works for me

df1.drop(1, inplace=True)
  • Related