Python Pandas Series: tail() function

In Pandas tail() function is similar to head() function. It is also used to explore data structures or data of a series without producing all of it. Alike head() function it is also a very convenient easy and quick method to try with data without actually dumping into it.

This function is used to return n rows from bottom of a dataframe or series.

Syntax

series.tail(n=5)

n: The number of rows. By Default n=5

Return: Series with bottom n rows.

Example

import pandas as pd

series_0=pd.Series([i for i in range(50)])

When n=10

series_0.tail(10)

Output

40    40
41    41
42    42
43    43
44    44
45    45
46    46
47    47
48    48
49    49
dtype: int64

When n is not given

series_0.tail()

Output:

45    45
46    46
47    47
48    48
49    49
dtype: int64
Wed, 11/03/2021 - 18:19

Authored by

Devanshi, is working as a Data Scientist with iVagus. She has expertise in Python, NumPy, Pandas and other data science technologies.