Home > Back-end >  Drop rows and reindex the data frame
Drop rows and reindex the data frame

Time:11-18

I have a dataframe of 1000 rows. Of which I have removed 20 rows. Now I want to reindex the df to (0-979) rows.

in_val = list(range(30,50)) # no of rows dropped df.drop(in_val, inplace=True)

The the df is with 980 rows, but the index is not 0-979. How can I do it?

CodePudding user response:

df.drop(in_val).reset_index(drop=True)

CodePudding user response:

Try this: df.reset_index(inplace=True)

  • Related