Skip to main content

head

The head method returns a table with a specific number of rows from the beginning of the source table.

Syntax#

table.head(numberOfRows)

Parameters#

ParameterTypeDescription
numberOfRowslong

The number of rows to return.

Returns#

A new table with a specific number of rows from the beginning of the source table.

Examples#

The following example filters the table to the first two rows.

from deephaven.TableTools import newTable, stringCol, intCol, doubleColfrom deephaven.conversion_utils import NULL_INT
source = newTable(    stringCol("Letter", "A", "C", "F", "B", "E", "D", "A"),    intCol("Number", NULL_INT, 2, 1, NULL_INT, 4, 5, 3),    stringCol("Color", "red", "blue", "orange", "purple", "yellow", "pink", "blue"),    intCol("Code", 12, 13, 11, NULL_INT, 16, 14, NULL_INT),)
result = source.head(2)

Related documentation#