How To Display Bottom ‘n’ Records Of DataFrame?
Table Of Contents:
- Syntax To Display Bottom Records Of Data Frame.
- Examples Of Displaying Bottom Records.
(1) Syntax:
DataFrame.tail(n=5)
Description:
Return the last n rows.
- This function returns the last n rows for the object based on position. It is useful for quickly testing if your object has the right type of data in it.
- For negative values of n, this function returns all rows except the last |n| rows, equivalent to
df[:n]
. - If n is larger than the number of rows, this function returns all rows.
Parameters:
- n: int, default 5 : Number of rows to select.
Returns:
- same type as caller: The last n rows of the caller object.
(2) Examples Of Displaying Bottom Records:
Example-1
import pandas as pd
path = "E:\Blogs\Pandas\Documents\Mall_Customers.csv"
customer_details = pd.read_csv(path)
customer_details
Output:
customer_details.tail()
Output:
Note:
- By default, it will display bottom 5 records of a DataFrame.
customer_details.tail(10)
Output:
Note:
- Here you can see the bottom 10 records of a DataFrame.