tail() Method | Teradata Python Package - tail() Method - Teradata Package for Python

Teradata® Package for Python User Guide

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Teradata Package for Python
Release Number
20.00
Published
December 2024
ft:locale
en-US
ft:lastEdition
2025-01-23
dita:mapPath
nvi1706202040305.ditamap
dita:ditavalPath
plt1683835213376.ditaval
dita:id
rkb1531260709148
lifecycle
latest
Product Category
Teradata Vantage

Use the tail() method to print the last n rows of a DataFrame.

The method takes the optional argument n number of rows to print. Default value is dependent on the value of the teradataml DataFrame display option max_rows, which is by default 10.

The DataFrame is sorted on the index column or the first column if there is no index column. The column type must support sorting.

Unsupported types include: 'BLOB', 'CLOB', 'ARRAY', 'VARRAY'.

Example 1: Print default number of rows

The following example prints the default last 10 rows of "admissions_train" sorted by id.
>>>df.tail()
   masters   gpa     stats programming admitted
id
38     yes  2.65  advanced    beginner        1
36      no  3.00  advanced      novice        0
35      no  3.68    novice    beginner        1
34     yes  3.85  advanced    beginner        0
32     yes  3.46  advanced    beginner        0
31     yes  3.50  advanced    beginner        1
33      no  3.55    novice      novice        1
37      no  3.52    novice      novice        1
39     yes  3.75  advanced    beginner        0
40     yes  3.95    novice    beginner        0

Example 2: Print n rows

The following example prints the last 3 rows of "admissions_train":
>>>df.tail(3)
   masters   gpa     stats programming admitted
id
38     yes  2.65  advanced    beginner        1
39     yes  3.75  advanced    beginner        0
40     yes  3.95    novice    beginner        0
The following example prints the last 15 rows of "admissions_train":
>>>df.tail(15)
   masters   gpa     stats programming admitted
id
38     yes  2.65  advanced    beginner        1
36      no  3.00  advanced      novice        0
35      no  3.68    novice    beginner        1
34     yes  3.85  advanced    beginner        0
32     yes  3.46  advanced    beginner        0
31     yes  3.50  advanced    beginner        1
30     yes  3.79  advanced      novice        0
29     yes  4.00    novice    beginner        0
28      no  3.93  advanced    advanced        1
27     yes  3.96  advanced    advanced        0
26     yes  3.57  advanced    advanced        1
33      no  3.55    novice      novice        1
37      no  3.52    novice      novice        1
39     yes  3.75  advanced    beginner        0
40     yes  3.95    novice    beginner        0