Skip to content

innovate.aggregate_time_series

All current Python definitions

View source · Source file SHA-256: 522871fe0b61b840b5f85b8f278beb2b79c7afd68645265ae3a68983d56d74e4

def aggregate_time_series(
data: pl.DataFrame | pl.LazyFrame,
frequency: str,
value_columns: list[str],
*,
time_column: str = 'time',
) -> pl.DataFrame: ...

Aggregate numeric values by daily, weekly or calendar-month windows.

The input is sorted by time and windows are left-closed. Daily and monthly results are upsampled between observed bounds and missing aggregate values are filled with zero. Weekly results keep only windows produced by grouping.

  • data: Polars DataFrame or LazyFrame; lazy input is collected before grouping.
  • frequency: "D" for calendar days, "W" for fixed 168-hour windows anchored at the earliest observation, or "M"/"ME" for calendar-month windows relabelled to month end.
  • value_columns: Nonempty list of distinct existing numeric columns to sum. Summation retains Polars’ handling of null and non-finite values.
  • time_column: Existing Date or Datetime column without nulls; defaults to "time". Numeric time axes are not accepted by this helper.

Sorted DataFrame with the timestamp label and requested value sums. Monthly labels are shifted to the final date of their calendar month.

  • ValueError: If frequency is unsupported, timestamps are not Date/Datetime or contain nulls, or value columns are empty, duplicated or nonnumeric.
  • polars.exceptions.PolarsError: If named columns are missing or grouping, sorting or upsampling fails.