Skip to content

Resampling

polars_ts.resampling

Group-aware temporal resampling for time series. Closes #62.

resample(df, rule, agg='mean', target_col='y', id_col='unique_id', time_col='ds', fill=None)

Resample a time series DataFrame to a new frequency.

Parameters

df Input DataFrame. rule Target frequency as a Polars duration string (e.g. "1d", "1h", "1w"). agg Aggregation for downsampling: "mean", "sum", "last", "first", "min", "max", "median". target_col Column to resample. id_col Column identifying each time series. time_col Column with timestamps. fill Fill strategy for upsampling gaps: "forward_fill", "interpolate", or None (leave nulls).

Returns

pl.DataFrame Resampled DataFrame with columns [id_col, time_col, target_col].