foundryts.functions.cumulative_aggregate

foundryts.functions.cumulative_aggregate(aggregate)

Returns a function that computes the cumulative aggregate of all values in a single time series.

The cumulative aggregate is calculated progressively for each point in the input time series, considering all preceding points up to and including the current point.

Aggregation functions supported:

Aggregation functionDescription
minSmallest value up to the current point in the time series.
maxLargest value up to the current point in the time series.
countCount of all points up to the current point in the
time series.
sumSum of all point values up to the current point.
productProduct of point values up to the current point.
meanAverage of all point values up to the current point.
standard_deviationStandard deviation of all point values up to the current
point.
differenceDifference between the current point’s value and the
first point’s value in the time series, providing the
relative change within the series.
percent_changePercent change between the current point’s value and the
first point’s value in the time series, providing the
relative rate of change within the series.
firstValue of the first point in the time series.
lastValue of the current (last) point in the time series.
  • Parameters: aggregate (str) – Aggregation function to apply on each point, use one of the values from Aggregation Function above.
  • Returns: A function that takes a single time series as input and computes the specified aggregate for each point, considering all preceding points up to the point being evaluated.
  • Return type: (FunctionNode) -> FunctionNode

Dataframe schema

Column nameTypeDescription
timestamppandas.TimestampTimestamp of the point
valueUnion[float, str]Value of the point
Note

This function is only applicable to numeric series.

Examples

Copied!
1 2 3 4 5 6 7 8 9 10 11 >>> series = F.points( ... (2, 10.0), (5, 20.0), (6, 30.0), (7, 40.0), (8, 50.0), (12, 60.0), name="series-1" ... ) >>> series.to_pandas() timestamp value 0 1970-01-01 00:00:00.000000002 10.0 1 1970-01-01 00:00:00.000000005 20.0 2 1970-01-01 00:00:00.000000006 30.0 3 1970-01-01 00:00:00.000000007 40.0 4 1970-01-01 00:00:00.000000008 50.0 5 1970-01-01 00:00:00.000000012 60.0
Copied!
1 2 3 4 5 6 7 8 9 >>> cumulative_agg = F.cumulative_aggregate("mean")(series) >>> cumulative_agg.to_pandas() timestamp value 0 1970-01-01 00:00:00.000000002 10.0 1 1970-01-01 00:00:00.000000005 15.0 2 1970-01-01 00:00:00.000000006 20.0 3 1970-01-01 00:00:00.000000007 25.0 4 1970-01-01 00:00:00.000000008 30.0 5 1970-01-01 00:00:00.000000012 35.0