time_stream.infill.AltDataDynamic#

class time_stream.infill.AltDataDynamic(alt_data_column, window_size, alt_df=None, min_threshold=0, max_threshold=None, window_side='both')[source]#

Infills missing values using an alternative data source and a dynamic correction factor derived from surrounding data.

For each contiguous gap in the original dataset, a time window is defined around the gap. A correction factor is computed as the ratio of the sum of the original data to the sum of the alternative data within this window. The alternative data corresponding to the missing interval is scaled by the correction factor to produce the infilled values.

The method defaults to using data on both sides of the gap. If window_side is specified as “left” or “right”, then only data left or right of the gap will be used.

Parameters:
  • alt_data_column (str)

  • window_size (str | Period | timedelta)

  • alt_df (DataFrame | None)

  • min_threshold (int)

  • max_threshold (int | None)

  • window_side (Literal['left', 'right', 'both'])

__init__(alt_data_column, window_size, alt_df=None, min_threshold=0, max_threshold=None, window_side='both')[source]#

Initialize the alternative data infill method.

Parameters:
  • alt_data_column (str) – Name of the column providing the alternative data.

  • window_size (str | Period | timedelta) – Time window around each gap used to calculate the correction factor. Accepts an ISO duration string, Period, or timedelta.

  • alt_df (DataFrame | None) – Optional separate DataFrame containing the alternative data. If None, alt_data_column must exist in the DataFrame passed to the infill method.

  • min_threshold (int) – Minimum number of data points required in the window to calculate a correction factor. Gaps with windows that have fewer points than the min_threshold are not infilled.

  • max_threshold (int | None) – Maximum number of data points to use per window. Points closest to the gap are used first.

  • window_side (Literal['left', 'right', 'both']) – Which side of each gap to use for the window. Defaults to “both”. “left” uses only data before the gap; “right” uses only data after.

Methods

__init__(alt_data_column, window_size[, ...])

Initialize the alternative data infill method.

apply(df, time_name, periodicity, infill_column)

Apply the infill method to the time series data.

available()

Return a sorted list of available registered keys.

get(spec, **kwargs)

Resolve spec to an instance of Self:

register(register_cls)

A method used as a decorator for subclasses to add to the register by its name attribute.

Attributes

name