Python Pandas Library tail function

27 June 2023 170 Reading time: 18 second

The tail function in the Pandas library returns the last n rows of a DataFrame. By default, the value of n is 5, but it can be optionally specified as a different value.

 

import pandas as pd

df = pd.read_csv('data.csv')
# Get the last 3 rows of the DataFrame
last_three_rows = df.tail(3)
print(last_three_rows)

 

Similar articles