TimeFrame.aggregate

TimeFrame.aggregate(aggregation_period, aggregation_function, columns=None, missing_criteria=None, aggregation_time_anchor=None, time_window=None, **kwargs)[source]

Apply an aggregation function to a column in this TimeFrame, check the aggregation satisfies user requirements and return a new derived TimeFrame containing the aggregated data.

Parameters:
  • aggregation_period (Period | str) – The period over which to aggregate the data

  • aggregation_function (Union[str, Type[AggregationFunction], AggregationFunction]) – The aggregation function to apply

  • columns (str | list[str] | None) – The column(s) containing the data to be aggregated. If omitted, will use all data columns.

  • missing_criteria (tuple[str, float | int] | None) – How the aggregation handles missing data

  • aggregation_time_anchor (TimeAnchor | None) – The time anchor for the aggregation result.

  • time_window (tuple[time, time] | tuple[time, time, str | ClosedInterval] | TimeWindow | None) –

    Optional restriction of which time-of-day observations are included in each aggregation period. Only supported when the aggregation period is daily or longer and the data periodicity is sub-daily.

    Accepts a TimeWindow instance, or a (start, end, closed[optional]) tuple, where:

    • start: datetime.time object for start of the window

    • end: datetime.time object for end of the window

    • closed: Define which sides of the interval are closed (inclusive) {‘both’, ‘left’, ‘right’, ‘none’} (default = “both”)

  • **kwargs – Parameters specific to the aggregation function.

Return type:

Self

Returns:

A TimeFrame containing the aggregated data.