drop last 5 rows pandas code example
Example 1: drop the last row of a dataframe
df.drop(df.tail(n).index,inplace=True) # drop last n rows
Example 2: how to remove last 2 rows in a dataframe
df1 = df.iloc[:3]
df.drop(df.tail(n).index,inplace=True) # drop last n rows
df1 = df.iloc[:3]