PANDAS remove row range from df

I want to remove m the number of rows from the bottom of the data frame. It is indexed by an integer (with holes). How can this be done?

pandas == 0.10.1 python == 2.7.3

+4
source share
2 answers

Use the slice to select the part you need:

df[:-m] 

If you want to remove some middle lines, you can use drop :

 df.drop(df.index[3:5]) 
+7
source

This should work

 df.head(len(df) - m) 
+1
source

All Articles