Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric Python packages. Pandas is one of those packages and makes importing and analyzing data much easier.
tail() method is used to return bottom n (5 by default) rows of a data frame or series.
n: integer value, number of rows to be returned
Return type: Dataframe with bottom n rows
To download the data set used in following example, click here.
In the following examples, the data frame used contains data of some NBA players. The image of data frame before any operations is attached below.
In this example, bottom 5 rows of data frame are returned and stored in a new variable. No parameter is passed to
.tail() method since by default it is 5.
As shown in the output image, it can be seen that the index of returned rows is ranging from 453 to 457. Hence, last 5 rows were returned.
Example #2: Calling on Series with n parameter()
In this example, the .tail() method is called on series with custom input of n parameter to return bottom 12 rows of the series.
As shown in the output image, top 12 rows ranging from 446 to 457th index position of the Salary column were returned.
- Python | pandas.to_markdown() in Pandas
- Add a Pandas series to another Pandas series
- Python | pandas.date_range() method
- Python | Filtering data with Pandas .query() method
- Python | Pandas Dataframe.describe() method
- Python | Pandas Dataframe/Series.head() method
- Python | Pandas Series.str.isspace() method
- Python | pandas.period_range() method
- Python | pandas.to_numeric method
- Python | Pandas Series.plot() method
- Python | Pandas DataFrame.to_html() method
- Python | Pandas DataFrame.to_latex() method
- Pandas.cut() method in Python
- Select first or last N rows in a Dataframe using head() and tail() method in Python-Pandas
- Python Pandas - get_dummies() method
- Reshape a pandas DataFrame using stack,unstack and melt method
- DataFrame.to_excel() method in Pandas
- DataFrame.read_pickle() method in Pandas
- Return multiple columns using Pandas apply() method
- Selecting with complex criteria using query method in Pandas
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.