In this post we will be creating a Python script that will remove the last n rows from Pandas data frame. Pandas is a Python library which is an amazing tool for data analysis and manipulation.
See below a sample of our data frame for this example.
The snippet of code below will then remove the last ‘3’ from our data frame.
df.drop(df.tail(3).index,inplace=True) # drop last 3 rows print(df)
If you are wanting to learn more about the basics of pandas, why not visit our pandas crash course by clicking here.