head() Method | DataFrame |Teradata Python - head() Method - Teradata Package for Python

Teradata® Package for Python User Guide

Product
Teradata Package for Python
Release Number
17.10
Published
May 2022
Language
English (United States)
Last Update
2022-08-18
dita:mapPath
rsu1641592952675.ditamap
dita:ditavalPath
ayr1485454803741.ditaval
dita:id
B700-4006
lifecycle
previous
Product Category
Teradata Vantage

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

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