head() 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 head() method to print the first n rows of a teradataml 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

This example prints the default 10 rows of "admissions_train":
>>> df.head()
   masters   gpa     stats programming admitted
id
3       no  3.70    novice    beginner        1
5       no  3.44    novice      novice        0
6      yes  3.50  beginner    advanced        1
7      yes  2.33    novice      novice        1
9       no  3.82  advanced    advanced        1
10      no  3.71  advanced    advanced        1
8       no  3.60  beginner    advanced        1
4      yes  3.50  beginner      novice        1
2      yes  3.76  beginner    beginner        0
1      yes  3.95  beginner    beginner        0

Examples: Print n rows

The following example prints 5 rows of "admissions_train":
>>> df.head(5)
   masters   gpa     stats programming admitted
id
3       no  3.70    novice    beginner        1
5       no  3.44    novice      novice        0
4      yes  3.50  beginner      novice        1
2      yes  3.76  beginner    beginner        0
1      yes  3.95  beginner    beginner        0
The following example prints 15 rows of "admissions_train":
>>> df.head(15)
   masters   gpa     stats programming admitted
id
3       no  3.70    novice    beginner        1
5       no  3.44    novice      novice        0
6      yes  3.50  beginner    advanced        1
7      yes  2.33    novice      novice        1
9       no  3.82  advanced    advanced        1
10      no  3.71  advanced    advanced        1
11      no  3.13  advanced    advanced        1
12      no  3.65    novice      novice        1
13      no  4.00  advanced      novice        1
14     yes  3.45  advanced    advanced        0
15     yes  4.00  advanced    advanced        1
8       no  3.60  beginner    advanced        1
4      yes  3.50  beginner      novice        1
2      yes  3.76  beginner    beginner        0
1      yes  3.95  beginner    beginner        0