Skip to main content
Version: Python

tail

The tail method returns a table with a specific number of rows from the end of the source table.

Syntax

table.tail(num_rows: int) -> Table

Parameters

ParameterTypeDescription
num_rowsint

The number of rows to return.

Returns

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

Examples

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

from deephaven import new_table
from deephaven.column import string_col, int_col, double_col
from deephaven.constants import NULL_INT

source = new_table([
string_col("Letter", ["A", "C", "F", "B", "E", "D", "A"]),
int_col("Number", [NULL_INT, 2, 1, NULL_INT, 4, 5, 3]),
string_col("Color", ["red", "blue", "orange", "purple", "yellow", "pink", "blue"]),
int_col("Code", [12, 14, 11, NULL_INT, 16, 14, NULL_INT]),
])


result = source.tail(2)

The following example uses tail on a blink table. Note that tail treats the blink table like an append-only table, showing the five rows that were most recently added to the table, regardless of what update cycle they are a part of.

from deephaven import time_table

source = time_table(period="PT0.5S", blink_table=True)

result = source.tail(5)

img