Skip to main content
Version: Python

slice_pct

The slice_pct method returns a table that is a subset of another table corresponding to the difference between the start and end row percentages. For example, for a table of size 10, slice_pct(0.1, 0.7) will return a subset from the second row to the seventh row. Similarly, slice_pct(0, 1) would return the entire table (because row positions run from 0 to size - 1). If the percentage arguments are outside of the range [0.0, 1.0], an error will occur.

caution

Attempting to use slice_pct on a blink table will raise an error.

Syntax

table.slice_pct(start_pct: float, end_pct: float) -> Table

Parameters

ParameterTypeDescription
start_pctfloat

The starting percentage point (inclusive) for rows to include in the result. The percentage arguments must be in the range [0.0, 1.0].

end_pctfloat

The ending percentage point (exclusive) for rows to include in the result. The percentage arguments must be in the range [0.0, 1.0].

Returns

A new table that is a subset of the source table.

Example

The following example filters the table to a subset between the tenth and 70th rows.

from deephaven import empty_table

source = empty_table(100).update(["X = i"])
result = source.slice_pct(0.1, 0.7)