tail() Method

Teradata® Python Package User Guide

brand
Teradata Vantage
prodname
Teradata Python Package
vrm_release
16.20
category
User Guide
featnum
B700-4006-098K

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: 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

Examples: 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