drop last row pandas

df.drop(df.tail(n).index,inplace=True) # drop last n rows

Here is what the above code is Doing:
1. We’re creating a new dataframe called df_new.
2. We’re using the .head() method to select the first n rows from df and assigning them to df_new.
3. We’re using the .drop() method to drop the last n rows from df and assigning the result to df.
4. We’re reassigning df to df_new.