emmin_time
emmin_time
creates a time-based EMMIN (exponential moving minimum) for an update_by
table operation. The formula for the time-based EMMIN of a column is:
Where:
- is the difference between time and in nanoseconds.
- is
decay_time
in nanoseconds, an input parameter to the method. - is the exponential moving minimum of at step .
- is the current value.
- denotes the time step, ranging from to , where is the number of elements in .
Syntax
emmin_time(
ts_col: str,
decay_time: Union[int, str],
cols: list[str],
op_control: OperationControl = None,
) -> UpdateByOperation
Parameters
Parameter | Type | Description |
---|---|---|
ts_col | str | The name of the column in the source table containing timestamps. |
decay_time | Union[int, str] | The decay rate. This can be expressed as an integer in nanoseconds or a string duration, e.g., |
cols | Union[str, list[str]] | The string names of columns to be operated on. These can include expressions to rename the output, e.g., |
op_control | OperationControl | Defines how special cases should behave. When |
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 two emmin_time
operations. Each uses a different decay_time
value to demonstrate how it affects the output.
from deephaven.updateby import emmin_time
from deephaven import empty_table
source = empty_table(20).update(
["Timestamp = '2023-05-01T00:00:00 ET' + i * SECOND", "X = randomInt(0,25)"]
)
result = source.update_by(
ops=[emmin_time(ts_col="Timestamp", decay_time="PT00:03:00.000", cols="EmMinX = X")]
)
result2 = source.update_by(
ops=[emmin_time(ts_col="Timestamp", decay_time="PT00:01:00.000", cols="EmMinX = X")]
)
- result
- result2
- source