Deleting last record from Pandas dataframe

While populating records into a dataframe, it is sometimes required to overwrite some records, based on their state changed. In such scenario when we delete the last record using the tail() function, the dataframe is not getting modified as expected from the below set of code.

# Import Required Libraries
import pandas as pd
 
# Create a dictionary for the dataframe
dict = {
  'Name': ['Swati Jain', 'Sumit Kalra', 'Archana Goel'],
  'Age' : [22, 20, 45],
  'Marks': [90, 84, -33]
}
 
# Converting Dictionary to
# Pandas Dataframe
df = pd.DataFrame(dict)
 
# Number of rows to drop
n = 1

print(df)
 
# Dropping last n rows using drop
df.drop(df.tail(n).index)
 
# Printing dataframe
print(df)


Output:

 Id  Name  Age  Marks
 0  Swati Jain  22  90
 1   Sumit Kalra  20  84
 2  Archana Goel  45  -33

 Id  Name  Age  Marks
 0  Swati Jain  22  90
 1   Sumit Kalra  20  84
 2  Archana Goel  45  -33