Skip to main content

Overview

Lag transforms allow you to compute lagged features and rolling statistics over grouped time series data. All transforms work with the GroupedArray structure and provide both transform() and update() methods for batch processing and incremental updates.

Basic Example

Rolling Window Examples

Rolling window operations compute statistics over a sliding window of observations.

Seasonal Rolling Examples

Seasonal rolling operations compute statistics over windows that respect seasonality patterns.

Expanding Window Examples

Expanding windows compute cumulative statistics from the start of each series.

Exponentially Weighted Mean Example

The exponentially weighted mean gives more weight to recent observations.

Update Method for Incremental Processing

All transforms provide an update() method for efficient incremental computation when new data arrives.

Available lag transformations

Lag

Bases: _BaseLagTransform Simple lag operator Parameters:
NameTypeDescriptionDefault
lagintNumber of periods to offsetrequired

RollingMean

Bases: _RollingBase Rolling Mean Parameters:
NameTypeDescriptionDefault
lagintNumber of periods to offset by before applying the transformation.required
window_sizeintLength of the rolling window.required
min_samplesintMinimum number of samples required to compute the statistic. If None, defaults to window_size.None
skipnaboolIf True, exclude NaN values from calculations. When False (default), NaN values propagate through the calculation.False

RollingStd

Bases: _RollingBase Rolling Standard Deviation Parameters:
NameTypeDescriptionDefault
lagintNumber of periods to offset by before applying the transformation.required
window_sizeintLength of the rolling window.required
min_samplesintMinimum number of samples required to compute the statistic. If None, defaults to window_size.None
skipnaboolIf True, exclude NaN values from calculations. When False (default), NaN values propagate through the calculation.False

RollingMin

Bases: _RollingBase Rolling Minimum Parameters:
NameTypeDescriptionDefault
lagintNumber of periods to offset by before applying the transformation.required
window_sizeintLength of the rolling window.required
min_samplesintMinimum number of samples required to compute the statistic. If None, defaults to window_size.None
skipnaboolIf True, exclude NaN values from calculations. When False (default), NaN values propagate through the calculation.False

RollingMax

Bases: _RollingBase Rolling Maximum Parameters:
NameTypeDescriptionDefault
lagintNumber of periods to offset by before applying the transformation.required
window_sizeintLength of the rolling window.required
min_samplesintMinimum number of samples required to compute the statistic. If None, defaults to window_size.None
skipnaboolIf True, exclude NaN values from calculations. When False (default), NaN values propagate through the calculation.False

RollingQuantile

Bases: _RollingBase Rolling quantile Parameters:
NameTypeDescriptionDefault
lagintNumber of periods to offset by before applying the transformationrequired
pfloatQuantile to computerequired
window_sizeintLength of the rolling windowrequired
min_samplesintMinimum number of samples required to compute the statistic. If None, defaults to window_size.None
skipnaboolIf True, exclude NaN values from calculations. When False (default), NaN values propagate through the calculation.False

SeasonalRollingMean

Bases: _SeasonalRollingBase Seasonal rolling Mean Parameters:
NameTypeDescriptionDefault
lagintNumber of periods to offset by before applying the transformationrequired
season_lengthintLength of the seasonal period, e.g. 7 for weekly datarequired
window_sizeintLength of the rolling windowrequired
min_samplesintMinimum number of samples required to compute the statistic. If None, defaults to window_size.None
skipnaboolIf True, exclude NaN values from calculations. When False (default), NaN values propagate through the calculation.False

SeasonalRollingStd

Bases: _SeasonalRollingBase Seasonal rolling Standard Deviation Parameters:
NameTypeDescriptionDefault
lagintNumber of periods to offset by before applying the transformationrequired
season_lengthintLength of the seasonal period, e.g. 7 for weekly datarequired
window_sizeintLength of the rolling windowrequired
min_samplesintMinimum number of samples required to compute the statistic. If None, defaults to window_size.None
skipnaboolIf True, exclude NaN values from calculations. When False (default), NaN values propagate through the calculation.False

SeasonalRollingMin

Bases: _SeasonalRollingBase Seasonal rolling Minimum Parameters:
NameTypeDescriptionDefault
lagintNumber of periods to offset by before applying the transformationrequired
season_lengthintLength of the seasonal period, e.g. 7 for weekly datarequired
window_sizeintLength of the rolling windowrequired
min_samplesintMinimum number of samples required to compute the statistic. If None, defaults to window_size.None
skipnaboolIf True, exclude NaN values from calculations. When False (default), NaN values propagate through the calculation.False

SeasonalRollingMax

Bases: _SeasonalRollingBase Seasonal rolling Maximum Parameters:
NameTypeDescriptionDefault
lagintNumber of periods to offset by before applying the transformationrequired
season_lengthintLength of the seasonal period, e.g. 7 for weekly datarequired
window_sizeintLength of the rolling windowrequired
min_samplesintMinimum number of samples required to compute the statistic. If None, defaults to window_size.None
skipnaboolIf True, exclude NaN values from calculations. When False (default), NaN values propagate through the calculation.False

SeasonalRollingQuantile

Bases: _SeasonalRollingBase Seasonal rolling statistic Parameters:
NameTypeDescriptionDefault
lagintNumber of periods to offset by before applying the transformationrequired
pfloatQuantile to computerequired
season_lengthintLength of the seasonal period, e.g. 7 for weekly datarequired
window_sizeintLength of the rolling windowrequired
min_samplesintMinimum number of samples required to compute the statistic. If None, defaults to window_size.None
skipnaboolIf True, exclude NaN values from calculations. When False (default), NaN values propagate through the calculation.False

ExpandingMean

Bases: _ExpandingBase Expanding Mean Parameters:
NameTypeDescriptionDefault
lagintNumber of periods to offset by before applying the transformationrequired
skipnaboolIf True, exclude NaN values from calculations. When False (default), NaN values propagate through the calculation.False

ExpandingStd

Bases: _ExpandingBase Expanding Standard Deviation Parameters:
NameTypeDescriptionDefault
lagintNumber of periods to offset by before applying the transformationrequired
skipnaboolIf True, exclude NaN values from calculations. When False (default), NaN values propagate through the calculation.False

ExpandingMin

Bases: _ExpandingComp Expanding Minimum Parameters:
NameTypeDescriptionDefault
lagintNumber of periods to offset by before applying the transformationrequired
skipnaboolIf True, exclude NaN values from calculations. When False (default), NaN values propagate through the calculation.False

ExpandingMax

Bases: _ExpandingComp Expanding Maximum Parameters:
NameTypeDescriptionDefault
lagintNumber of periods to offset by before applying the transformationrequired
skipnaboolIf True, exclude NaN values from calculations. When False (default), NaN values propagate through the calculation.False

ExpandingQuantile

Bases: _BaseLagTransform Expanding quantile Parameters:
NameTypeDescriptionDefault
lagintNumber of periods to offset by before applying the transformationrequired
pfloatQuantile to computerequired
skipnaboolIf True, exclude NaN values from calculations. When False (default), NaN values propagate through the calculation.False

ExponentiallyWeightedMean

Bases: _BaseLagTransform Exponentially weighted mean Parameters:
NameTypeDescriptionDefault
lagintNumber of periods to offset by before applying the transformationrequired
alphafloatSmoothing factorrequired
skipnaboolIf True, exclude NaN values from calculations using forward-fill behavior. When False (default), NaN values propagate through the calculation.False