Use the head() method to print the first n rows of a teradataml DataFrame.
Optional Parameters
- n
- Specifies the number of rows to select. If 'deterministic' is False, 'n' should (0, 100].
Default value: 10
- deterministic
- Specifies whether to select the first n rows from the sorted DataFrame or not.
- If True, the first n rows of the sorted DataFrame are selected.
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'.
- If False, a random sample of n rows is selected.
Default value: True.
- If True, the first n rows of the sorted DataFrame are selected.
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
Example 3: Print 3 rows of "admissions_train" with deterministic argument set to False
>>> df.head(3, deterministic=False)
masters gpa stats programming admitted
id
40 yes 3.95 Novice Beginner 0
19 yes 1.98 Advanced Advanced 0
38 yes 2.65 Advanced Beginner 1