tail_pct
The tail_pct
method returns a table with a specific percentage of rows from the end of the source table.
caution
Attempting to use tail_pct
on a blink table will raise an error.
Syntax
table.tail_pct(pct: float) -> Table
Parameters
Parameter | Type | Description |
---|---|---|
pct | float | The percentage of rows to return. This value must be given as a floating-point number between 0 (0%) to 1 (100%). |
Returns
A new table with a specific percentage of rows from the end of the source table.
Examples
The following example filters the table to the last 40% and 33.3333333% of 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_pct(pct=0.40)
result1 = source.tail_pct(pct=0.333333333)
- source
- result
- result1