pydeephaven.updateby¶
This module defines the UpdateByOperation and provides factory functions to create specific UpdateByOperations instances.
- class BadDataBehavior(value)[source]¶
Bases:
Enum
An Enum defining ways to handle invalid data during update-by operations.
- POISON = 4¶
Allow the bad data to poison the result. This is only valid for use with NaN
- RESET = 2¶
Reset the state for the bucket to None when invalid data is encountered
- SKIP = 3¶
Skip and do not process the invalid data without changing state
- THROW = 1¶
Throw an exception and abort processing when bad data is encountered
- class DeltaControl(value)[source]¶
Bases:
Enum
An Enum defining ways to handle null values during update-by Delta operations where delta operations return the difference between the current row and the previous row.
- NULL_DOMINATES = 1¶
A valid value following a null value returns null
- VALUE_DOMINATES = 2¶
A valid value following a null value returns the valid value
- ZERO_DOMINATES = 3¶
A valid value following a null value returns zero
- class MathContext(value)[source]¶
Bases:
Enum
An Enum for predefined precision and rounding settings in numeric calculations.
- DECIMAL128 = (34, 7)¶
a precision setting matching the IEEE 754R Decimal128 format, 34 digits, rounding is half-even
- DECIMAL32 = (7, 7)¶
a precision setting matching the IEEE 754R Decimal32 format, 7 digits, rounding is half-even
- DECIMAL64 = (16, 7)¶
a precision setting matching the IEEE 754R Decimal64 format, 16 digits, rounding is half-even
- UNLIMITED = (0, 5)¶
unlimited precision arithmetic, rounding is half-up
- class OperationControl(on_null=BadDataBehavior.SKIP, on_nan=BadDataBehavior.SKIP, big_value_context=MathContext.DECIMAL128)[source]¶
Bases:
_UpdateByBase
A OperationControl represents control parameters for performing operations with the table UpdateByOperation.
Initializes an OperationControl for use with certain UpdateByOperation, such as EMAs.
- Parameters:
on_null (BadDataBehavior) – the behavior for when null values are encountered, default is SKIP
on_nan (BadDataBehavior) – the behavior for when NaN values are encountered, default is SKIP
big_value_context (MathContext) – the context to use when processing arbitrary precision numeric values, default is DECIMAL128.
- class UpdateByOperation(ub_column)[source]¶
Bases:
_UpdateByBase
A UpdateByOperation represents an operator for the Table update-by operation.
- cum_max(cols)[source]¶
Creates a cumulative maximum UpdateByOperation for the supplied column names.
- Parameters:
cols (Union[str, List[str]]) – the column(s) to be operated on, can include expressions to rename the output, i.e. “new_col = col”; when empty, update_by performing the operation on all applicable columns.
- Return type:
- Returns:
UpdateByOperation
- cum_min(cols)[source]¶
Creates a cumulative minimum UpdateByOperation for the supplied column names.
- Parameters:
cols (Union[str, List[str]]) – the column(s) to be operated on, can include expressions to rename the output, i.e. “new_col = col”; when empty, update_by performs the operation on all applicable columns.
- Return type:
- Returns:
UpdateByOperation
- cum_prod(cols)[source]¶
Creates a cumulative product UpdateByOperation for the supplied column names.
- Parameters:
cols (Union[str, List[str]]) – the column(s) to be operated on, can include expressions to rename the output, i.e. “new_col = col”; when empty, update_by performs the operation on all applicable columns.
- Return type:
- Returns:
UpdateByOperation
- cum_sum(cols)[source]¶
Creates a cumulative sum UpdateByOperation for the supplied column names.
- Parameters:
cols (Union[str, List[str]]) – the column(s) to be operated on, can include expressions to rename the output, i.e. “new_col = col”; when empty, update_by performs the operation on all applicable columns.
- Return type:
- Returns:
UpdateByOperation
- delta(cols, delta_control=DeltaControl.NULL_DOMINATES)[source]¶
Creates a delta UpdateByOperation for the supplied column names. The Delta operation produces values by computing the difference between the current value and the previous value. When the current value is null, this operation will output null. When the current value is valid, the output will depend on the DeltaControl provided.
When delta_control is not provided or set to NULL_DOMINATES, a value following a null value returns null. When delta_control is set to VALUE_DOMINATES, a value following a null value returns the value. When delta_control is set to ZERO_DOMINATES, a value following a null value returns zero.
- Parameters:
cols (Union[str, List[str]]) – the column(s) to be operated on, can include expressions to rename the output, i.e. “new_col = col”; when empty, update_by performs the operation on all applicable columns.
delta_control (DeltaControl) – defines how special cases should behave; when None, the default DeltaControl settings of VALUE_DOMINATES will be used
- Return type:
- Returns:
an UpdateByOperation
- Raises:
DHError –
- ema_tick(decay_ticks, cols, op_control=None)[source]¶
Creates an EMA (exponential moving average) UpdateByOperation for the supplied column names, using ticks as the decay unit.
- The formula used is
a = e^(-1 / decay_ticks) ema_next = a * ema_last + (1 - a) * value
- Parameters:
decay_ticks (float) – the decay rate in ticks
cols (Union[str, List[str]]) – the column(s) to be operated on, can include expressions to rename the output, i.e. “new_col = col”; when empty, update_by performs the operation on all applicable columns.
op_control (OperationControl) – defines how special cases should behave; when None, the default OperationControl settings as specified in
__init__()
will be used
- Return type:
- Returns:
an UpdateByOperation
- Raises:
DHError –
- ema_time(ts_col, decay_time, cols, op_control=None)[source]¶
Creates an EMA (exponential moving average) UpdateByOperation for the supplied column names, using time as the decay unit.
- The formula used is
a = e^(-dt / decay_time) ema_next = a * ema_last + (1 - a) * value
- Args:
ts_col (str): the column in the source table to use for timestamps decay_time (Union[int, str]): the decay rate, can be expressed as an integer in nanoseconds or a time
interval string, e.g. “PT00:00:.001” or “PT5M”
- cols (Union[str, List[str]]): the column(s) to be operated on, can include expressions to rename the output,
i.e. “new_col = col”; when empty, update_by performs the operation on all applicable columns.
- op_control (OperationControl): defines how special cases should behave; when None, the default OperationControl
settings as specified in
__init__()
will be used
- Return type:
- Returns:
an UpdateByOperation
- Raises:
DHError –
- emmax_tick(decay_ticks, cols, op_control=None)[source]¶
Creates an EM Max (exponential moving maximum) UpdateByOperation for the supplied column names, using ticks as the decay unit.
- The formula used is
a = e^(-1 / decay_ticks) em_val_next = max(a * em_val_last, value)
- Parameters:
decay_ticks (float) – the decay rate in ticks
cols (Union[str, List[str]]) – the column(s) to be operated on, can include expressions to rename the output, i.e. “new_col = col”; when empty, update_by performs the operation on all applicable columns.
op_control (OperationControl) – defines how special cases should behave; when None, the default OperationControl settings as specified in
__init__()
will be used
- Return type:
- Returns:
an UpdateByOperation
- Raises:
DHError –
- emmax_time(ts_col, decay_time, cols, op_control=None)[source]¶
Creates an EM Max (exponential moving maximum) UpdateByOperation for the supplied column names, using time as the decay unit.
- The formula used is
a = e^(-dt / decay_time) em_val_next = max(a * em_val_last, value)
- Args:
ts_col (str): the column in the source table to use for timestamps decay_time (Union[int, str]): the decay rate, can be expressed as an integer in nanoseconds or a time
interval string, e.g. “PT00:00:.001” or “PT5M”
- cols (Union[str, List[str]]): the column(s) to be operated on, can include expressions to rename the output,
i.e. “new_col = col”; when empty, update_by performs the operation on all applicable columns.
- op_control (OperationControl): defines how special cases should behave; when None, the default OperationControl
settings as specified in
__init__()
will be used
- Return type:
- Returns:
an UpdateByOperation
- Raises:
DHError –
- emmin_tick(decay_ticks, cols, op_control=None)[source]¶
Creates an EM Min (exponential moving minimum) UpdateByOperation for the supplied column names, using ticks as the decay unit.
- The formula used is
a = e^(-1 / decay_ticks) em_val_next = min(a * em_val_last, value)
- Parameters:
decay_ticks (float) – the decay rate in ticks
cols (Union[str, List[str]]) – the column(s) to be operated on, can include expressions to rename the output, i.e. “new_col = col”; when empty, update_by performs the operation on all applicable columns.
op_control (OperationControl) – defines how special cases should behave; when None, the default OperationControl settings as specified in
__init__()
will be used
- Return type:
- Returns:
an UpdateByOperation
- Raises:
DHError –
- emmin_time(ts_col, decay_time, cols, op_control=None)[source]¶
Creates an EM Min (exponential moving minimum) UpdateByOperation for the supplied column names, using time as the decay unit.
- The formula used is
a = e^(-dt / decay_time) em_val_next = min(a * em_val_last, value)
- Args:
ts_col (str): the column in the source table to use for timestamps decay_time (Union[int, str]): the decay rate, can be expressed as an integer in nanoseconds or a time
interval string, e.g. “PT00:00:.001” or “PT5M”
- cols (Union[str, List[str]]): the column(s) to be operated on, can include expressions to rename the output,
i.e. “new_col = col”; when empty, update_by performs the operation on all applicable columns.
- op_control (OperationControl): defines how special cases should behave; when None, the default OperationControl
settings as specified in
__init__()
will be used
- Return type:
- Returns:
an UpdateByOperation
- Raises:
DHError –
- ems_tick(decay_ticks, cols, op_control=None)[source]¶
Creates an EMS (exponential moving sum) UpdateByOperation for the supplied column names, using ticks as the decay unit.
- The formula used is
a = e^(-1 / decay_ticks) ems_next = a * ems_last + value
- Parameters:
decay_ticks (float) – the decay rate in ticks
cols (Union[str, List[str]]) – the column(s) to be operated on, can include expressions to rename the output, i.e. “new_col = col”; when empty, update_by performs the operation on all applicable columns.
op_control (OperationControl) – defines how special cases should behave; when None, the default OperationControl settings as specified in
__init__()
will be used
- Return type:
- Returns:
an UpdateByOperation
- Raises:
DHError –
- ems_time(ts_col, decay_time, cols, op_control=None)[source]¶
Creates an EMS (exponential moving sum) UpdateByOperation for the supplied column names, using time as the decay unit.
- The formula used is
a = e^(-dt / decay_time) eems_next = a * ems_last + value
- Args:
ts_col (str): the column in the source table to use for timestamps decay_time (Union[int, str]): the decay rate, can be expressed as an integer in nanoseconds or a time
interval string, e.g. “PT00:00:.001” or “PT5M”
- cols (Union[str, List[str]]): the column(s) to be operated on, can include expressions to rename the output,
i.e. “new_col = col”; when empty, update_by performs the operation on all applicable columns.
- op_control (OperationControl): defines how special cases should behave; when None, the default OperationControl
settings as specified in
__init__()
will be used
- Return type:
- Returns:
an UpdateByOperation
- Raises:
DHError –
- emstd_tick(decay_ticks, cols, op_control=None)[source]¶
Creates an EM Std (exponential moving standard deviation) UpdateByOperation for the supplied column names, using ticks as the decay unit.
- The formula used is
a = e^(-1 / decay_ticks) variance = a * (prevVariance + (1 − a) * (x − prevEma)^2) ema = a * prevEma + x std = sqrt(variance)
- Parameters:
decay_ticks (float) – the decay rate in ticks
cols (Union[str, List[str]]) – the column(s) to be operated on, can include expressions to rename the output, i.e. “new_col = col”; when empty, update_by performs the operation on all applicable columns.
op_control (OperationControl) – defines how special cases should behave; when None, the default OperationControl settings as specified in
__init__()
will be used
- Return type:
- Returns:
an UpdateByOperation
- Raises:
DHError –
- emstd_time(ts_col, decay_time, cols, op_control=None)[source]¶
Creates an EM Std (exponential moving standard deviation) UpdateByOperation for the supplied column names, using time as the decay unit.
- The formula used is
a = e^(-dt / timeDecay) variance = a * (prevVariance + (1 − a) * (x − prevEma)^2) ema = a * prevEma + x std = sqrt(variance)
- Args:
ts_col (str): the column in the source table to use for timestamps decay_time (Union[int, str]): the decay rate, can be expressed as an integer in nanoseconds or a time
interval string, e.g. “PT00:00:.001” or “PT5M”
- cols (Union[str, List[str]]): the column(s) to be operated on, can include expressions to rename the output,
i.e. “new_col = col”; when empty, update_by performs the operation on all applicable columns.
- op_control (OperationControl): defines how special cases should behave; when None, the default OperationControl
settings as specified in
__init__()
will be used
- Return type:
- Returns:
an UpdateByOperation
- Raises:
DHError –
- forward_fill(cols)[source]¶
Creates a forward fill UpdateByOperation for the supplied column names. Null values in the column(s) are replaced by the last known non-null values. This operation is forward only.
- Parameters:
cols (Union[str, List[str]]) – the column(s) to be operated on, can include expressions to rename the output, i.e. “new_col = col”; when empty, update_by performs the operation on all applicable columns.
- Return type:
- Returns:
UpdateByOperation
- rolling_avg_tick(cols, rev_ticks, fwd_ticks=0)[source]¶
Creates a rolling average UpdateByOperation for the supplied column names, using ticks as the windowing unit. Ticks are row counts, and you may specify the reverse and forward window in number of rows to include. The current row is considered to belong to the reverse window but not the forward window. Also, negative values are allowed and can be used to generate completely forward or completely reverse windows.
- Here are some examples of window values:
rev_ticks = 1, fwd_ticks = 0 - contains only the current row rev_ticks = 10, fwd_ticks = 0 - contains 9 previous rows and the current row rev_ticks = 0, fwd_ticks = 10 - contains the following 10 rows, excludes the current row rev_ticks = 10, fwd_ticks = 10 - contains the previous 9 rows, the current row and the 10 rows following rev_ticks = 10, fwd_ticks = -5 - contains 5 rows, beginning at 9 rows before, ending at 5 rows before the
current row (inclusive)
- rev_ticks = 11, fwd_ticks = -1 - contains 10 rows, beginning at 10 rows before, ending at 1 row before the
current row (inclusive)
- rev_ticks = -5, fwd_ticks = 10 - contains 5 rows, beginning 5 rows following, ending at 10 rows following the
current row (inclusive)
- Parameters:
cols (Union[str, List[str]]) – the column(s) to be operated on, can include expressions to rename the output, i.e. “new_col = col”; when empty, update_by performs the rolling average operation on all columns.
rev_ticks (int) – the look-behind window size (in rows/ticks)
fwd_ticks (int) – the look-forward window size (int rows/ticks), default is 0
- Return type:
- Returns:
an UpdateByOperation
- Raises:
DHError –
- rolling_avg_time(ts_col, cols, rev_time, fwd_time=0)[source]¶
Creates a rolling average UpdateByOperation for the supplied column names, using time as the windowing unit. This function accepts nanoseconds or time strings as the reverse and forward window parameters. Negative values are allowed and can be used to generate completely forward or completely reverse windows. A row containing a null in the timestamp column belongs to no window and will not be considered in the windows of other rows; its output will be null.
- Here are some examples of window values:
rev_time = 0, fwd_time = 0 - contains rows that exactly match the current row timestamp rev_time = “PT00:10:00”, fwd_time = “0” - contains rows from 10m before through the current row timestamp (
inclusive)
- rev_time = 0, fwd_time = 600_000_000_000 - contains rows from the current row through 10m following the
current row timestamp (inclusive)
- rev_time = “PT00:10:00”, fwd_time = “PT00:10:00” - contains rows from 10m before through 10m following
the current row timestamp (inclusive)
- rev_time = “PT00:10:00”, fwd_time = “-PT00:05:00” - contains rows from 10m before through 5m before the
current row timestamp (inclusive), this is a purely backwards looking window
- rev_time = “-PT00:05:00”, fwd_time = “PT00:10:00”} - contains rows from 5m following through 10m
following the current row timestamp (inclusive), this is a purely forwards looking window
- Parameters:
ts_col (str) – the timestamp column for determining the window
cols (Union[str, List[str]]) – the column(s) to be operated on, can include expressions to rename the output, i.e. “new_col = col”; when empty, update_by performs the rolling sum operation on all columns.
rev_time (Union[int, str]) – the look-behind window size, can be expressed as an integer in nanoseconds or a time interval string, e.g. “PT00:00:.001” or “PT5M”
fwd_time (Union[int, str]) – the look-ahead window size, can be expressed as an integer in nanoseconds or a time interval string, e.g. “PT00:00:.001” or “PT5M”, default is 0
- Return type:
- Returns:
an UpdateByOperation
- Raises:
DHError –
- rolling_count_tick(cols, rev_ticks, fwd_ticks=0)[source]¶
Creates a rolling count UpdateByOperation for the supplied column names, using ticks as the windowing unit. Ticks are row counts, and you may specify the reverse and forward window in number of rows to include. The current row is considered to belong to the reverse window but not the forward window. Also, negative values are allowed and can be used to generate completely forward or completely reverse windows.
- Here are some examples of window values:
rev_ticks = 1, fwd_ticks = 0 - contains only the current row rev_ticks = 10, fwd_ticks = 0 - contains 9 previous rows and the current row rev_ticks = 0, fwd_ticks = 10 - contains the following 10 rows, excludes the current row rev_ticks = 10, fwd_ticks = 10 - contains the previous 9 rows, the current row and the 10 rows following rev_ticks = 10, fwd_ticks = -5 - contains 5 rows, beginning at 9 rows before, ending at 5 rows before the
current row (inclusive)
- rev_ticks = 11, fwd_ticks = -1 - contains 10 rows, beginning at 10 rows before, ending at 1 row before the
current row (inclusive)
- rev_ticks = -5, fwd_ticks = 10 - contains 5 rows, beginning 5 rows following, ending at 10 rows following the
current row (inclusive)
- Parameters:
cols (Union[str, List[str]]) – the column(s) to be operated on, can include expressions to rename the output, i.e. “new_col = col”; when empty, update_by performs the rolling count operation on all columns.
rev_ticks (int) – the look-behind window size (in rows/ticks)
fwd_ticks (int) – the look-forward window size (int rows/ticks), default is 0
- Return type:
- Returns:
an UpdateByOperation
- Raises:
DHError –
- rolling_count_time(ts_col, cols, rev_time, fwd_time=0)[source]¶
Creates a rolling count UpdateByOperation for the supplied column names, using time as the windowing unit. This function accepts nanoseconds or time strings as the reverse and forward window parameters. Negative values are allowed and can be used to generate completely forward or completely reverse windows. A row containing a null in the timestamp column belongs to no window and will not be considered in the windows of other rows; its output will be null.
- Here are some examples of window values:
rev_time = 0, fwd_time = 0 - contains rows that exactly match the current row timestamp rev_time = “PT00:10:00”, fwd_time = “0” - contains rows from 10m before through the current row timestamp (
inclusive)
- rev_time = 0, fwd_time = 600_000_000_000 - contains rows from the current row through 10m following the
current row timestamp (inclusive)
- rev_time = “PT00:10:00”, fwd_time = “PT00:10:00” - contains rows from 10m before through 10m following
the current row timestamp (inclusive)
- rev_time = “PT00:10:00”, fwd_time = “-PT00:05:00” - contains rows from 10m before through 5m before the
current row timestamp (inclusive), this is a purely backwards looking window
- rev_time = “-PT00:05:00”, fwd_time = “PT00:10:00”} - contains rows from 5m following through 10m
following the current row timestamp (inclusive), this is a purely forwards looking window
- Parameters:
ts_col (str) – the timestamp column for determining the window
cols (Union[str, List[str]]) – the column(s) to be operated on, can include expressions to rename the output, i.e. “new_col = col”; when empty, update_by performs the rolling sum operation on all columns.
rev_time (Union[int, str]) – the look-behind window size, can be expressed as an integer in nanoseconds or a time interval string, e.g. “PT00:00:.001” or “PT5M”
fwd_time (Union[int, str]) – the look-ahead window size, can be expressed as an integer in nanoseconds or a time interval string, e.g. “PT00:00:.001” or “PT5M”, default is 0
- Return type:
- Returns:
an UpdateByOperation
- Raises:
DHError –
- rolling_formula_tick(formula, formula_param, cols, rev_ticks, fwd_ticks=0)[source]¶
Creates a rolling formula UpdateByOperation for the supplied column names, using ticks as the windowing unit. Ticks are row counts, and you may specify the reverse and forward window in number of rows to include. The current row is considered to belong to the reverse window but not the forward window. Also, negative values are allowed and can be used to generate completely forward or completely reverse windows.
- User-defined formula can contain a combination of any of the following:
- Built-in functions such as min, max, etc.Mathematical arithmetic such as *, +, /, etc.User-defined functions
- Here are some examples of window values:
- rev_ticks = 1, fwd_ticks = 0 - contains only the current rowrev_ticks = 10, fwd_ticks = 0 - contains 9 previous rows and the current rowrev_ticks = 0, fwd_ticks = 10 - contains the following 10 rows, excludes the current rowrev_ticks = 10, fwd_ticks = 10 - contains the previous 9 rows, the current row and the 10 rows followingrev_ticks = 10, fwd_ticks = -5 - contains 5 rows, beginning at 9 rows before, ending at 5 rows before the current row (inclusive)rev_ticks = 11, fwd_ticks = -1 - contains 10 rows, beginning at 10 rows before, ending at 1 row before the current row (inclusive)rev_ticks = -5, fwd_ticks = 10 - contains 5 rows, beginning 5 rows following, ending at 10 rows following the current row (inclusive)
- Parameters:
formula (str) – the user defined formula to apply to each group.
formula_param (str) – the parameter name for the input column’s vector within the formula. If formula is max(each), then each is the formula_param.
cols (Union[str, List[str]]) – the column(s) to be operated on, can include expressions to rename the output, i.e. “new_col = col”; when empty, update_by performs the rolling formula operation on all columns.
rev_ticks (int) – the look-behind window size (in rows/ticks)
fwd_ticks (int) – the look-forward window size (int rows/ticks), default is 0
- Return type:
- Returns:
an UpdateByOperation
- Raises:
DHError –
- rolling_formula_time(ts_col, formula, formula_param, cols, rev_time, fwd_time=0)[source]¶
Creates a rolling formula UpdateByOperation for the supplied column names, using time as the windowing unit. This function accepts nanoseconds or time strings as the reverse and forward window parameters. Negative values are allowed and can be used to generate completely forward or completely reverse windows. A row containing a null in the timestamp column belongs to no window and will not be considered in the windows of other rows; its output will be null.
- User-defined formula can contain a combination of any of the following:
- Built-in functions such as min, max, etc.Mathematical arithmetic such as *, +, /, etc.User-defined functions
- Here are some examples of window values:
- rev_time = 0, fwd_time = 0 - contains rows that exactly match the current row timestamprev_time = “PT00:10:00”, fwd_time = “0” - contains rows from 10m before through the current row timestamp ( inclusive)rev_time = 0, fwd_time = 600_000_000_000 - contains rows from the current row through 10m following the current row timestamp (inclusive)rev_time = “PT00:10:00”, fwd_time = “PT00:10:00” - contains rows from 10m before through 10m following the current row timestamp (inclusive)rev_time = “PT00:10:00”, fwd_time = “-PT00:05:00” - contains rows from 10m before through 5m before the current row timestamp (inclusive), this is a purely backwards looking windowrev_time = “-PT00:05:00”, fwd_time = “PT00:10:00” - contains rows from 5m following through 10m following the current row timestamp (inclusive), this is a purely forwards looking window
- Parameters:
ts_col (str) – the timestamp column for determining the window
formula (str) – the user defined formula to apply to each group.
formula_param (str) – the parameter name for the input column’s vector within the formula. If formula is max(each), then each is the formula_param.
cols (Union[str, List[str]]) – the column(s) to be operated on, can include expressions to rename the output, i.e. “new_col = col”; when empty, update_by performs the rolling formula operation on all columns.
rev_time (int) – the look-behind window size, can be expressed as an integer in nanoseconds or a time interval string, e.g. “PT00:00:00.001” or “PT5M”
fwd_time (int) – the look-ahead window size, can be expressed as an integer in nanoseconds or a time interval string, e.g. “PT00:00:00.001” or “PT5M”, default is 0
- Return type:
- Returns:
an UpdateByOperation
- Raises:
DHError –
- rolling_group_tick(cols, rev_ticks, fwd_ticks=0)[source]¶
Creates a rolling group UpdateByOperation for the supplied column names, using ticks as the windowing unit. Ticks are row counts, and you may specify the reverse and forward window in number of rows to include. The current row is considered to belong to the reverse window but not the forward window. Also, negative values are allowed and can be used to generate completely forward or completely reverse windows. :rtype:
UpdateByOperation
- Here are some examples of window values:
rev_ticks = 1, fwd_ticks = 0 - contains only the current row rev_ticks = 10, fwd_ticks = 0 - contains 9 previous rows and the current row rev_ticks = 0, fwd_ticks = 10 - contains the following 10 rows, excludes the current row rev_ticks = 10, fwd_ticks = 10 - contains the previous 9 rows, the current row and the 10 rows following rev_ticks = 10, fwd_ticks = -5 - contains 5 rows, beginning at 9 rows before, ending at 5 rows before the
current row (inclusive)
- rev_ticks = 11, fwd_ticks = -1 - contains 10 rows, beginning at 10 rows before, ending at 1 row before the
current row (inclusive)
- rev_ticks = -5, fwd_ticks = 10 - contains 5 rows, beginning 5 rows following, ending at 10 rows following the
current row (inclusive)
- Args:
- cols (Union[str, List[str]]): the column(s) to be operated on, can include expressions to rename the output,
i.e. “new_col = col”; when empty, update_by performs the rolling sum operation on all columns.
rev_ticks (int): the look-behind window size (in rows/ticks) fwd_ticks (int): the look-forward window size (int rows/ticks), default is 0
- Returns:
an UpdateByOperation
- Raises:
DHError
- rolling_group_time(ts_col, cols, rev_time, fwd_time=0)[source]¶
Creates a rolling group UpdateByOperation for the supplied column names, using time as the windowing unit. This function accepts nanoseconds or time strings as the reverse and forward window parameters. Negative values are allowed and can be used to generate completely forward or completely reverse windows. A row containing a null in the timestamp column belongs to no window and will not be considered in the windows of other rows; its output will be null.
- Here are some examples of window values:
rev_time = 0, fwd_time = 0 - contains rows that exactly match the current row timestamp rev_time = “PT00:10:00”, fwd_time = “0” - contains rows from 10m before through the current row timestamp (
inclusive)
- rev_time = 0, fwd_time = 600_000_000_000 - contains rows from the current row through 10m following the
current row timestamp (inclusive)
- rev_time = “PT00:10:00”, fwd_time = “PT00:10:00” - contains rows from 10m before through 10m following
the current row timestamp (inclusive)
- rev_time = “PT00:10:00”, fwd_time = “-PT00:05:00” - contains rows from 10m before through 5m before the
current row timestamp (inclusive), this is a purely backwards looking window
- rev_time = “-PT00:05:00”, fwd_time = “PT00:10:00”} - contains rows from 5m following through 10m
following the current row timestamp (inclusive), this is a purely forwards looking window
- Parameters:
ts_col (str) – the timestamp column for determining the window
cols (Union[str, List[str]]) – the column(s) to be operated on, can include expressions to rename the output, i.e. “new_col = col”; when empty, update_by performs the rolling sum operation on all columns.
rev_time (Union[int, str]) – the look-behind window size, can be expressed as an integer in nanoseconds or a time interval string, e.g. “PT00:00:.001” or “PT5M”
fwd_time (Union[int, str]) – the look-ahead window size, can be expressed as an integer in nanoseconds or a time interval string, e.g. “PT00:00:.001” or “PT5M”, default is 0
- Return type:
- Returns:
an UpdateByOperation
- Raises:
DHError –
- rolling_max_tick(cols, rev_ticks, fwd_ticks=0)[source]¶
Creates a rolling maximum UpdateByOperation for the supplied column names, using ticks as the windowing unit. Ticks are row counts, and you may specify the reverse and forward window in number of rows to include. The current row is considered to belong to the reverse window but not the forward window. Also, negative values are allowed and can be used to generate completely forward or completely reverse windows.
- Here are some examples of window values:
rev_ticks = 1, fwd_ticks = 0 - contains only the current row rev_ticks = 10, fwd_ticks = 0 - contains 9 previous rows and the current row rev_ticks = 0, fwd_ticks = 10 - contains the following 10 rows, excludes the current row rev_ticks = 10, fwd_ticks = 10 - contains the previous 9 rows, the current row and the 10 rows following rev_ticks = 10, fwd_ticks = -5 - contains 5 rows, beginning at 9 rows before, ending at 5 rows before the
current row (inclusive)
- rev_ticks = 11, fwd_ticks = -1 - contains 10 rows, beginning at 10 rows before, ending at 1 row before the
current row (inclusive)
- rev_ticks = -5, fwd_ticks = 10 - contains 5 rows, beginning 5 rows following, ending at 10 rows following the
current row (inclusive)
- Parameters:
cols (Union[str, List[str]]) – the column(s) to be operated on, can include expressions to rename the output, i.e. “new_col = col”; when empty, update_by performs the rolling maximum operation on all columns.
rev_ticks (int) – the look-behind window size (in rows/ticks)
fwd_ticks (int) – the look-forward window size (int rows/ticks), default is 0
- Return type:
- Returns:
an UpdateByOperation
- Raises:
DHError –
- rolling_max_time(ts_col, cols, rev_time, fwd_time=0)[source]¶
Creates a rolling maximum UpdateByOperation for the supplied column names, using time as the windowing unit. This function accepts nanoseconds or time strings as the reverse and forward window parameters. Negative values are allowed and can be used to generate completely forward or completely reverse windows. A row containing a null in the timestamp column belongs to no window and will not be considered in the windows of other rows; its output will be null.
- Here are some examples of window values:
rev_time = 0, fwd_time = 0 - contains rows that exactly match the current row timestamp rev_time = “PT00:10:00”, fwd_time = “0” - contains rows from 10m before through the current row timestamp (
inclusive)
- rev_time = 0, fwd_time = 600_000_000_000 - contains rows from the current row through 10m following the
current row timestamp (inclusive)
- rev_time = “PT00:10:00”, fwd_time = “PT00:10:00” - contains rows from 10m before through 10m following
the current row timestamp (inclusive)
- rev_time = “PT00:10:00”, fwd_time = “-PT00:05:00” - contains rows from 10m before through 5m before the
current row timestamp (inclusive), this is a purely backwards looking window
- rev_time = “-PT00:05:00”, fwd_time = “PT00:10:00”} - contains rows from 5m following through 10m
following the current row timestamp (inclusive), this is a purely forwards looking window
- Parameters:
ts_col (str) – the timestamp column for determining the window
cols (Union[str, List[str]]) – the column(s) to be operated on, can include expressions to rename the output, i.e. “new_col = col”; when empty, update_by performs the rolling sum operation on all columns.
rev_time (Union[int, str]) – the look-behind window size, can be expressed as an integer in nanoseconds or a time interval string, e.g. “PT00:00:.001” or “PT5M”
fwd_time (Union[int, str]) – the look-ahead window size, can be expressed as an integer in nanoseconds or a time interval string, e.g. “PT00:00:.001” or “PT5M”, default is 0
- Return type:
- Returns:
an UpdateByOperation
- Raises:
DHError –
- rolling_min_tick(cols, rev_ticks, fwd_ticks=0)[source]¶
Creates a rolling minimum UpdateByOperation for the supplied column names, using ticks as the windowing unit. Ticks are row counts, and you may specify the reverse and forward window in number of rows to include. The current row is considered to belong to the reverse window but not the forward window. Also, negative values are allowed and can be used to generate completely forward or completely reverse windows.
- Here are some examples of window values:
rev_ticks = 1, fwd_ticks = 0 - contains only the current row rev_ticks = 10, fwd_ticks = 0 - contains 9 previous rows and the current row rev_ticks = 0, fwd_ticks = 10 - contains the following 10 rows, excludes the current row rev_ticks = 10, fwd_ticks = 10 - contains the previous 9 rows, the current row and the 10 rows following rev_ticks = 10, fwd_ticks = -5 - contains 5 rows, beginning at 9 rows before, ending at 5 rows before the
current row (inclusive)
- rev_ticks = 11, fwd_ticks = -1 - contains 10 rows, beginning at 10 rows before, ending at 1 row before the
current row (inclusive)
- rev_ticks = -5, fwd_ticks = 10 - contains 5 rows, beginning 5 rows following, ending at 10 rows following the
current row (inclusive)
- Parameters:
cols (Union[str, List[str]]) – the column(s) to be operated on, can include expressions to rename the output, i.e. “new_col = col”; when empty, update_by performs the rolling minimum operation on all columns.
rev_ticks (int) – the look-behind window size (in rows/ticks)
fwd_ticks (int) – the look-forward window size (int rows/ticks), default is 0
- Return type:
- Returns:
an UpdateByOperation
- Raises:
DHError –
- rolling_min_time(ts_col, cols, rev_time, fwd_time=0)[source]¶
Creates a rolling minimum UpdateByOperation for the supplied column names, using time as the windowing unit. This function accepts nanoseconds or time strings as the reverse and forward window parameters. Negative values are allowed and can be used to generate completely forward or completely reverse windows. A row containing a null in the timestamp column belongs to no window and will not be considered in the windows of other rows; its output will be null.
- Here are some examples of window values:
rev_time = 0, fwd_time = 0 - contains rows that exactly match the current row timestamp rev_time = “PT00:10:00”, fwd_time = “0” - contains rows from 10m before through the current row timestamp (
inclusive)
- rev_time = 0, fwd_time = 600_000_000_000 - contains rows from the current row through 10m following the
current row timestamp (inclusive)
- rev_time = “PT00:10:00”, fwd_time = “PT00:10:00” - contains rows from 10m before through 10m following
the current row timestamp (inclusive)
- rev_time = “PT00:10:00”, fwd_time = “-PT00:05:00” - contains rows from 10m before through 5m before the
current row timestamp (inclusive), this is a purely backwards looking window
- rev_time = “-PT00:05:00”, fwd_time = “PT00:10:00”} - contains rows from 5m following through 10m
following the current row timestamp (inclusive), this is a purely forwards looking window
- Parameters:
ts_col (str) – the timestamp column for determining the window
cols (Union[str, List[str]]) – the column(s) to be operated on, can include expressions to rename the output, i.e. “new_col = col”; when empty, update_by performs the rolling sum operation on all columns.
rev_time (Union[int, str]) – the look-behind window size, can be expressed as an integer in nanoseconds or a time interval string, e.g. “PT00:00:.001” or “PT5M”
fwd_time (Union[int, str]) – the look-ahead window size, can be expressed as an integer in nanoseconds or a time interval string, e.g. “PT00:00:.001” or “PT5M”, default is 0
- Return type:
- Returns:
an UpdateByOperation
- Raises:
DHError –
- rolling_prod_tick(cols, rev_ticks, fwd_ticks=0)[source]¶
Creates a rolling product UpdateByOperation for the supplied column names, using ticks as the windowing unit. Ticks are row counts, and you may specify the reverse and forward window in number of rows to include. The current row is considered to belong to the reverse window but not the forward window. Also, negative values are allowed and can be used to generate completely forward or completely reverse windows.
- Here are some examples of window values:
rev_ticks = 1, fwd_ticks = 0 - contains only the current row rev_ticks = 10, fwd_ticks = 0 - contains 9 previous rows and the current row rev_ticks = 0, fwd_ticks = 10 - contains the following 10 rows, excludes the current row rev_ticks = 10, fwd_ticks = 10 - contains the previous 9 rows, the current row and the 10 rows following rev_ticks = 10, fwd_ticks = -5 - contains 5 rows, beginning at 9 rows before, ending at 5 rows before the
current row (inclusive)
- rev_ticks = 11, fwd_ticks = -1 - contains 10 rows, beginning at 10 rows before, ending at 1 row before the
current row (inclusive)
- rev_ticks = -5, fwd_ticks = 10 - contains 5 rows, beginning 5 rows following, ending at 10 rows following the
current row (inclusive)
- Parameters:
cols (Union[str, List[str]]) – the column(s) to be operated on, can include expressions to rename the output, i.e. “new_col = col”; when empty, update_by performs the rolling product operation on all columns.
rev_ticks (int) – the look-behind window size (in rows/ticks)
fwd_ticks (int) – the look-forward window size (int rows/ticks), default is 0
- Return type:
- Returns:
an UpdateByOperation
- Raises:
DHError –
- rolling_prod_time(ts_col, cols, rev_time, fwd_time=0)[source]¶
Creates a rolling product UpdateByOperation for the supplied column names, using time as the windowing unit. This function accepts nanoseconds or time strings as the reverse and forward window parameters. Negative values are allowed and can be used to generate completely forward or completely reverse windows. A row containing a null in the timestamp column belongs to no window and will not be considered in the windows of other rows; its output will be null.
- Here are some examples of window values:
rev_time = 0, fwd_time = 0 - contains rows that exactly match the current row timestamp rev_time = “PT00:10:00”, fwd_time = “0” - contains rows from 10m before through the current row timestamp (
inclusive)
- rev_time = 0, fwd_time = 600_000_000_000 - contains rows from the current row through 10m following the
current row timestamp (inclusive)
- rev_time = “PT00:10:00”, fwd_time = “PT00:10:00” - contains rows from 10m before through 10m following
the current row timestamp (inclusive)
- rev_time = “PT00:10:00”, fwd_time = “-PT00:05:00” - contains rows from 10m before through 5m before the
current row timestamp (inclusive), this is a purely backwards looking window
- rev_time = “-PT00:05:00”, fwd_time = “PT00:10:00”} - contains rows from 5m following through 10m
following the current row timestamp (inclusive), this is a purely forwards looking window
- Parameters:
ts_col (str) – the timestamp column for determining the window
cols (Union[str, List[str]]) – the column(s) to be operated on, can include expressions to rename the output, i.e. “new_col = col”; when empty, update_by performs the rolling sum operation on all columns.
rev_time (Union[int, str]) – the look-behind window size, can be expressed as an integer in nanoseconds or a time interval string, e.g. “PT00:00:.001” or “PT5M”
fwd_time (Union[int, str]) – the look-ahead window size, can be expressed as an integer in nanoseconds or a time interval string, e.g. “PT00:00:.001” or “PT5M”, default is 0
- Return type:
- Returns:
an UpdateByOperation
- Raises:
DHError –
- rolling_std_tick(cols, rev_ticks, fwd_ticks=0)[source]¶
Creates a rolling sample standard deviation UpdateByOperation for the supplied column names, using ticks as the windowing unit. Ticks are row counts, and you may specify the reverse and forward window in number of rows to include. The current row is considered to belong to the reverse window but not the forward window. Also, negative values are allowed and can be used to generate completely forward or completely reverse windows.
Sample standard deviation is computed using Bessel’s correction, which ensures that the sample variance will be an unbiased estimator of population variance.
- Here are some examples of window values:
rev_ticks = 1, fwd_ticks = 0 - contains only the current row rev_ticks = 10, fwd_ticks = 0 - contains 9 previous rows and the current row rev_ticks = 0, fwd_ticks = 10 - contains the following 10 rows, excludes the current row rev_ticks = 10, fwd_ticks = 10 - contains the previous 9 rows, the current row and the 10 rows following rev_ticks = 10, fwd_ticks = -5 - contains 5 rows, beginning at 9 rows before, ending at 5 rows before the
current row (inclusive)
- rev_ticks = 11, fwd_ticks = -1 - contains 10 rows, beginning at 10 rows before, ending at 1 row before the
current row (inclusive)
- rev_ticks = -5, fwd_ticks = 10 - contains 5 rows, beginning 5 rows following, ending at 10 rows following the
current row (inclusive)
- Parameters:
cols (Union[str, List[str]]) – the column(s) to be operated on, can include expressions to rename the output, i.e. “new_col = col”; when empty, update_by performs the rolling sample standard deviation operation on all columns.
rev_ticks (int) – the look-behind window size (in rows/ticks)
fwd_ticks (int) – the look-forward window size (int rows/ticks), default is 0
- Return type:
- Returns:
an UpdateByOperation
- Raises:
DHError –
- rolling_std_time(ts_col, cols, rev_time, fwd_time=0)[source]¶
Creates a rolling sample standard deviation UpdateByOperation for the supplied column names, using time as the windowing unit. This function accepts nanoseconds or time strings as the reverse and forward window parameters. Negative values are allowed and can be used to generate completely forward or completely reverse windows. A row containing a null in the timestamp column belongs to no window and will not be considered in the windows of other rows; its output will be null.
Sample standard deviation is computed using Bessel’s correction, which ensures that the sample variance will be an unbiased estimator of population variance.
- Here are some examples of window values:
rev_time = 0, fwd_time = 0 - contains rows that exactly match the current row timestamp rev_time = “PT00:10:00”, fwd_time = “0” - contains rows from 10m before through the current row timestamp (
inclusive)
- rev_time = 0, fwd_time = 600_000_000_000 - contains rows from the current row through 10m following the
current row timestamp (inclusive)
- rev_time = “PT00:10:00”, fwd_time = “PT00:10:00” - contains rows from 10m before through 10m following
the current row timestamp (inclusive)
- rev_time = “PT00:10:00”, fwd_time = “-PT00:05:00” - contains rows from 10m before through 5m before the
current row timestamp (inclusive), this is a purely backwards looking window
- rev_time = “-PT00:05:00”, fwd_time = “PT00:10:00”} - contains rows from 5m following through 10m
following the current row timestamp (inclusive), this is a purely forwards looking window
- Parameters:
ts_col (str) – the timestamp column for determining the window
cols (Union[str, List[str]]) – the column(s) to be operated on, can include expressions to rename the output, i.e. “new_col = col”; when empty, update_by performs the rolling sum operation on all columns.
rev_time (Union[int, str]) – the look-behind window size, can be expressed as an integer in nanoseconds or a time interval string, e.g. “PT00:00:.001” or “PT5M”
fwd_time (Union[int, str]) – the look-ahead window size, can be expressed as an integer in nanoseconds or a time interval string, e.g. “PT00:00:.001” or “PT5M”, default is 0
- Return type:
- Returns:
an UpdateByOperation
- Raises:
DHError –
- rolling_sum_tick(cols, rev_ticks, fwd_ticks=0)[source]¶
Creates a rolling sum UpdateByOperation for the supplied column names, using ticks as the windowing unit. Ticks are row counts, and you may specify the reverse and forward window in number of rows to include. The current row is considered to belong to the reverse window but not the forward window. Also, negative values are allowed and can be used to generate completely forward or completely reverse windows.
- Here are some examples of window values:
rev_ticks = 1, fwd_ticks = 0 - contains only the current row rev_ticks = 10, fwd_ticks = 0 - contains 9 previous rows and the current row rev_ticks = 0, fwd_ticks = 10 - contains the following 10 rows, excludes the current row rev_ticks = 10, fwd_ticks = 10 - contains the previous 9 rows, the current row and the 10 rows following rev_ticks = 10, fwd_ticks = -5 - contains 5 rows, beginning at 9 rows before, ending at 5 rows before the
current row (inclusive)
- rev_ticks = 11, fwd_ticks = -1 - contains 10 rows, beginning at 10 rows before, ending at 1 row before the
current row (inclusive)
- rev_ticks = -5, fwd_ticks = 10 - contains 5 rows, beginning 5 rows following, ending at 10 rows following the
current row (inclusive)
- Parameters:
cols (Union[str, List[str]]) – the column(s) to be operated on, can include expressions to rename the output, i.e. “new_col = col”; when empty, update_by performs the rolling sum operation on all columns.
rev_ticks (int) – the look-behind window size (in rows/ticks)
fwd_ticks (int) – the look-forward window size (int rows/ticks), default is 0
- Return type:
- Returns:
an UpdateByOperation
- Raises:
DHError –
- rolling_sum_time(ts_col, cols, rev_time, fwd_time=0)[source]¶
Creates a rolling sum UpdateByOperation for the supplied column names, using time as the windowing unit. This function accepts nanoseconds or time strings as the reverse and forward window parameters. Negative values are allowed and can be used to generate completely forward or completely reverse windows. A row containing a null in the timestamp column belongs to no window and will not be considered in the windows of other rows; its output will be null.
- Here are some examples of window values:
rev_time = 0, fwd_time = 0 - contains rows that exactly match the current row timestamp rev_time = “PT00:10:00”, fwd_time = “0” - contains rows from 10m before through the current row timestamp
(inclusive)
- rev_time = 0, fwd_time = 600_000_000_000 - contains rows from the current row through 10m following the
current row timestamp (inclusive)
- rev_time = “PT00:10:00”, fwd_time = “PT00:10:00” - contains rows from 10m before through 10m following
the current row timestamp (inclusive)
- rev_time = “PT00:10:00”, fwd_time = “-PT00:05:00” - contains rows from 10m before through 5m before the
current row timestamp (inclusive), this is a purely backwards looking window
- rev_time = “-PT00:05:00”, fwd_time = “PT00:10:00”} - contains rows from 5m following through 10m
following the current row timestamp (inclusive), this is a purely forwards looking window
- Parameters:
ts_col (str) – the timestamp column for determining the window
cols (Union[str, List[str]]) – the column(s) to be operated on, can include expressions to rename the output, i.e. “new_col = col”; when empty, update_by performs the rolling sum operation on all columns.
rev_time (Union[int, str]) – the look-behind window size, can be expressed as an integer in nanoseconds or a time interval string, e.g. “PT00:00:.001” or “PT5M”
fwd_time (Union[int, str]) – the look-ahead window size, can be expressed as an integer in nanoseconds or a time interval string, e.g. “PT00:00:.001” or “PT5M”, default is 0
- Return type:
- Returns:
an UpdateByOperation
- Raises:
DHError –
- rolling_wavg_tick(wcol, cols, rev_ticks, fwd_ticks=0)[source]¶
Creates a rolling weighted average UpdateByOperation for the supplied column names, using ticks as the windowing unit. Ticks are row counts, and you may specify the reverse and forward window in number of rows to include. The current row is considered to belong to the reverse window but not the forward window. Also, negative values are allowed and can be used to generate completely forward or completely reverse windows.
- Here are some examples of window values:
rev_ticks = 1, fwd_ticks = 0 - contains only the current row rev_ticks = 10, fwd_ticks = 0 - contains 9 previous rows and the current row rev_ticks = 0, fwd_ticks = 10 - contains the following 10 rows, excludes the current row rev_ticks = 10, fwd_ticks = 10 - contains the previous 9 rows, the current row and the 10 rows following rev_ticks = 10, fwd_ticks = -5 - contains 5 rows, beginning at 9 rows before, ending at 5 rows before the
current row (inclusive)
- rev_ticks = 11, fwd_ticks = -1 - contains 10 rows, beginning at 10 rows before, ending at 1 row before the
current row (inclusive)
- rev_ticks = -5, fwd_ticks = 10 - contains 5 rows, beginning 5 rows following, ending at 10 rows following the
current row (inclusive)
- Parameters:
cols (Union[str, List[str]]) – the column(s) to be operated on, can include expressions to rename the output, i.e. “new_col = col”; when empty, update_by performs the rolling weighted average operation on all columns.
wcol (str) – the column containing the weight values
rev_ticks (int) – the look-behind window size (in rows/ticks)
fwd_ticks (int) – the look-forward window size (int rows/ticks), default is 0
- Return type:
- Returns:
an UpdateByOperation
- Raises:
DHError –
- rolling_wavg_time(ts_col, wcol, cols, rev_time, fwd_time=0)[source]¶
Creates a rolling weighted average UpdateByOperation for the supplied column names, using time as the windowing unit. This function accepts nanoseconds or time strings as the reverse and forward window parameters. Negative values are allowed and can be used to generate completely forward or completely reverse windows. A row containing a null in the timestamp column belongs to no window and will not be considered in the windows of other rows; its output will be null.
- Here are some examples of window values:
rev_time = 0, fwd_time = 0 - contains rows that exactly match the current row timestamp rev_time = “PT00:10:00”, fwd_time = “0” - contains rows from 10m before through the current row timestamp (
inclusive)
- rev_time = 0, fwd_time = 600_000_000_000 - contains rows from the current row through 10m following the
current row timestamp (inclusive)
- rev_time = “PT00:10:00”, fwd_time = “PT00:10:00” - contains rows from 10m before through 10m following
the current row timestamp (inclusive)
- rev_time = “PT00:10:00”, fwd_time = “-PT00:05:00” - contains rows from 10m before through 5m before the
current row timestamp (inclusive), this is a purely backwards looking window
- rev_time = “-PT00:05:00”, fwd_time = “PT00:10:00”} - contains rows from 5m following through 10m
following the current row timestamp (inclusive), this is a purely forwards looking window
- Parameters:
ts_col (str) – the timestamp column for determining the window
cols (Union[str, List[str]]) – the column(s) to be operated on, can include expressions to rename the output, i.e. “new_col = col”; when empty, update_by performs the rolling weighted average operation on all columns.
wcol (str) – the column containing the weight values
rev_time (Union[int, str]) – the look-behind window size, can be expressed as an integer in nanoseconds or a time interval string, e.g. “PT00:00:.001” or “PT5M”
fwd_time (Union[int, str]) – the look-ahead window size, can be expressed as an integer in nanoseconds or a time interval string, e.g. “PT00:00:.001” or “PT5M”, default is 0
- Return type:
- Returns:
an UpdateByOperation
- Raises:
DHError –