deephaven.updateby

This module supports building various operations for use with the update-by Table operation.

class BadDataBehavior(value)[source]

Bases: Enum

An Enum defining ways to handle invalid data during update-by operations.

POISON = io.deephaven.api.updateby.BadDataBehavior(objectRef=0x56435af94eea)

Allow the bad data to poison the result. This is only valid for use with NaN

RESET = io.deephaven.api.updateby.BadDataBehavior(objectRef=0x56435af94eda)

Reset the state for the bucket to None when invalid data is encountered

SKIP = io.deephaven.api.updateby.BadDataBehavior(objectRef=0x56435af94ee2)

Skip and do not process the invalid data without changing state

THROW = io.deephaven.api.updateby.BadDataBehavior(objectRef=0x56435af94ed2)

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 = io.deephaven.api.updateby.DeltaControl(objectRef=0x56435afa64e2)

A valid value following a null value returns null

VALUE_DOMINATES = io.deephaven.api.updateby.DeltaControl(objectRef=0x56435afa64ea)

A valid value following a null value returns the valid value

ZERO_DOMINATES = io.deephaven.api.updateby.DeltaControl(objectRef=0x56435afa64f2)

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 calculation.

DECIMAL128 = java.math.MathContext(objectRef=0x56435afa651a)

a precision setting matching the IEEE 754R Decimal128 format, 34 digits, rounding is half-even

DECIMAL32 = java.math.MathContext(objectRef=0x56435afa650a)

a precision setting matching the IEEE 754R Decimal32 format, 7 digits, rounding is half-even

DECIMAL64 = java.math.MathContext(objectRef=0x56435afa6512)

a precision setting matching the IEEE 754R Decimal64 format, 16 digits, rounding is half-even

UNLIMITED = java.math.MathContext(objectRef=0x56435afa6502)

unlimited precision arithmetic, rounding is half-up

class OperationControl(on_null=BadDataBehavior.SKIP, on_nan=BadDataBehavior.SKIP, big_value_context=MathContext.DECIMAL128)[source]

Bases: JObjectWrapper

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 (Java BigDecimal/BigInteger), default is DECIMAL128.

Raises:

DHError

j_object_type

alias of OperationControl

class UpdateByOperation(j_updateby_op)[source]

Bases: JObjectWrapper

A UpdateByOperation represents an operator for the Table update-by operation.

j_object_type

alias of UpdateByOperation

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 performs the cumulative maximum operation on all the applicable columns.

Return type:

UpdateByOperation

Returns:

an UpdateByOperation

Raises:

DHError

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 cumulative minimum operation on all the applicable columns.

Return type:

UpdateByOperation

Returns:

an UpdateByOperation

Raises:

DHError

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 performing the cumulative product operation on all the applicable columns.

Return type:

UpdateByOperation

Returns:

an UpdateByOperation

Raises:

DHError

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 cumulative sum operation on all the applicable columns.

Return type:

UpdateByOperation

Returns:

an UpdateByOperation

Raises:

DHError

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 delta operation on all the 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:

UpdateByOperation

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_first = first_value
ema_current = a * ema_prev + (1 - a) * current_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:

UpdateByOperation

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

dt_current = current_timestamp - prev_timestamp
a_current = e^(-dt_current / decay_time)
ema_first = first_value
ema_current = a_current * ema_prev + (1 - a_current) * current_value
Parameters:
  • 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: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:

UpdateByOperation

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)
emmax_first = first_value
emmax_current = max(a * emmax_prev, current_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 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:

UpdateByOperation

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

dt_current = current_timestamp - prev_timestamp
a_current = e^(-dt_current / decay_time)
emmax_first = first_value
emmax_current = max(a_current * emmax_prev, current_value)
Parameters:
  • 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: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 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:

UpdateByOperation

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)
emmin_first = first_value
emmin_current = min(a * emmin_prev, current_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 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:

UpdateByOperation

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

dt_current = current_timestamp - prev_timestamp
a_current = e^(-dt_current / decay_time)
emmin_first = first_value
emmin_current = min(a_current * emmin_last, value)
Parameters:
  • 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: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 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:

UpdateByOperation

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_first = first_value
ems_current = a * ems_prev + current_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:

UpdateByOperation

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

dt_current = current_timestamp - prev_timestamp
a_current = e^(-dt_current / decay_time)
ems_first = first_value
ems_current = a_current * ems_prev + current_value
Parameters:
  • 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: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 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:

UpdateByOperation

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)
em_variance_current = a * (em_variance_prev + (1 − a) * (current_value − ema_prev)^2)
emstd_current = sqrt(em_variance_current)
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 ems operation on all 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:

UpdateByOperation

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

dt_current = current_timestamp - prev_timestamp
a_current = e^(-dt_current / decay_time)
em_variance_first = 0
em_variance_current = a_current * (em_variance_prev + (1 − a_current) * (current_value − ema_prev)^2)
emstd_current = sqrt(em_variance_current)
Parameters:
  • 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: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 ems operation on all 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:

UpdateByOperation

Returns:

an UpdateByOperation

Raises:

DHError

forward_fill(cols)[source]

Creates a forward fill UpdateByOperation for the supplied column names. Null values in the columns 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 forward fill operation on all columns.

Return type:

UpdateByOperation

Returns:

an UpdateByOperation

Raises:

DHError

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:

UpdateByOperation

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 average 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:

UpdateByOperation

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:

UpdateByOperation

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 count 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:

UpdateByOperation

Returns:

an UpdateByOperation

Raises:

DHError

rolling_formula_tick(formula, formula_param=None, cols=None, rev_ticks=0, 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.

There are two variants of this call. The preferred variant requires the formula to provide the output column name and specific input column names in the following format:

rolling_formula_tick(formula=’output_col=(input_col1 + input_col2) * input_col3’, rev_ticks=10, fwd_ticks=0)

This form does not accept formula_param or cols arguments because the input and output columns are explicitly set within the formula string.

The second (deprecated) variant allows the user to apply a formula expression to one input column, producing one input column. In this call the formula_param is used as a placeholder for the input column name and the cols argument is used to identify the output column name and the input source column when applying the formula. If multiple input/output pairs are specified in the cols argument, the formula will be applied to each column in the list. The format for this call is the following:

rolling_formula_tick(formula=’min(x * x + 5)’, formula_param=’x’, cols=[‘out1=inputCol1’,’out2=inputCol2’], rev_ticks=10, fwd_ticks=0)
User-defined formula can contain a combination 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 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:
  • formula (str) – the user defined formula to apply to each group.

  • formula_param (str) – If provided, supplies the parameter name for the input column’s vector within the formula. If formula is max(each), then each is the formula_param. Default is None, implying the formula argument specifies the input and output columns.

  • cols (Union[str, List[str]]) – If provided, supplies the column(s) to operate on, can include expressions to rename the output, i.e. “new_col = col”. If omitted and the formula_param is provided, 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:

UpdateByOperation

Returns:

an UpdateByOperation

Raises:

DHError

rolling_formula_time(ts_col, formula, formula_param=None, cols=None, rev_time=0, 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.

There are two variants of this call. The preferred variant requires the formula to provide the output column name and specific input column names in the following format:

rolling_formula_time(ts_col=’tstamp’, formula=’output_col=(input_col1 + input_col2) * input_col3’, rev_time=’PT00:10:00’, fwd_time=’0’`)

This form does not accept formula_param or cols arguments because the input and output columns are explicitly set within the formula string.

The second (deprecated) variant allows the user to apply a formula expression to one input column, producing one input column. In this call the formula_param is used as a placeholder for the input column name and the cols argument is used to identify the output column name and the input source column when applying the formula. If multiple input/output pairs are specified in the cols argument, the formula will be applied to each column in the list. The format for this call is the following:

rolling_formula_time(ts_col=’tstamp’, formula=’min(x * x + 5)’, formula_param=’x’, rev_time=’PT00:10:00’, fwd_time=’0’`)
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 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

  • formula (str) – the user defined formula to apply to each group.

  • formula_param (str) – If provided, supplies the parameter name for the input column’s vector within the formula. If formula is max(each), then each is the formula_param. Default is None, implying the formula argument specifies the input and output columns.

  • cols (Union[str, List[str]]) – If provided, supplies the column(s) to operate on, can include expressions to rename the output, i.e. “new_col = col”. If omitted and the formula_param is provided, 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:

UpdateByOperation

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.

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 group 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:

UpdateByOperation

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 group 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:

UpdateByOperation

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:

UpdateByOperation

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 maximum 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:

UpdateByOperation

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:

UpdateByOperation

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 minimum 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:

UpdateByOperation

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:

UpdateByOperation

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 product 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:

UpdateByOperation

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:

UpdateByOperation

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 sample standard deviation 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:

UpdateByOperation

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:

UpdateByOperation

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 (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:

UpdateByOperation

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:
  • wcol (str) – the column containing the weight values

  • 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.

  • 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:

UpdateByOperation

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

  • wcol (str) – the column containing the weight values

  • 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.

  • 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:

UpdateByOperation

Returns:

an UpdateByOperation

Raises:

DHError