Pandas DataFrame tail() Method
Example
Return the last 5 rows of the DataFrame.
In this example we use a .csv file called data.csv
import pandas as pd
df = pd.read_csv('data.csv')
print(df.tail())
Try it Yourself »
Definition and Usage
The tail()
method returns a specified number
of last rows.
The tail()
method returns the last 5 rows if
a number is not specified.
Note: The column names will also be returned, in addition to the specified rows.
Syntax
dataframe.tail(n)
Parameters
Parameter | Description |
---|---|
n | Optional. The number of rows to return. Default value is 5. |
Return Value
A DataFrame with headers and the specified number of rows.