how to drop last 2 rows in dataframe pandas code example
Example 1: drop last row pandas
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]