rolling_max_time
rolling_max_time
creates a rolling maximum in an update_by
table operation using time as the windowing unit. Time can be specified as integer numbers of nanoseconds or strings. The rolling maximum can be calculated using forward and/or backward windows.
Syntax
rolling_max_time(
ts_col: str,
cols: list[str],
rev_time: Union[int, str],
fwd_time: Union[int, str],
) -> UpdateByOperation
Parameters
Parameter | Type | Description |
---|---|---|
ts_col | str | The name of the column containing timestamps. |
cols | list[str] | The column(s) to be operated on. These can include expressions to rename the output (e.g., |
rev_time | Union[int,str] | The look-behind window size. This can be expressed as an integer in nanoseconds or a string duration, e.g., |
fwd_time | Union[int,str] | The look-forward window size. This can be expressed as an integer in nanoseconds or a string duration, e.g., |
Returns
An UpdateByOperation
to be used in an update_by
table operation.
Examples
The following example performs an update_by
on the source
table using three rolling_max_time
operations. Each uses different rev_time
and fwd_time
values to show how they affect the output.
from deephaven.updateby import rolling_max_time
from deephaven.time import to_j_instant
from deephaven import empty_table
base_time = to_j_instant("2023-01-01T00:00:00 ET")
source = empty_table(10).update(
[
"Timestamp = base_time + i * SECOND",
"Letter = (i % 2 == 0) ? `A` : `B`",
"X = randomInt(0, 25)",
]
)
op_before = rolling_max_time(
ts_col="Timestamp", cols=["WindowBefore = X"], rev_time="PT5S", fwd_time=int(-1e9)
)
op_after = rolling_max_time(
ts_col="Timestamp", cols=["WindowAfter = X"], rev_time="PT5S", fwd_time=int(3e9)
)
op_middle = rolling_max_time(
ts_col="Timestamp", cols=["WindowMiddle = X"], rev_time="PT1S", fwd_time="PT1S"
)
result = source.update_by(ops=[op_before, op_after, op_middle], by="Letter")
- source
- result