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 dataaggregation_function (
Union[str,Type[AggregationFunction],AggregationFunction]) – The aggregation function to applycolumns (
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 dataaggregation_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
TimeWindowinstance, or a(start, end, closed[optional])tuple, where:start:datetime.timeobject for start of the windowend:datetime.timeobject for end of the windowclosed: 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.