snowflake.snowpark.DataFrameAnalyticsFunctions.time_series_agg¶
- DataFrameAnalyticsFunctions.time_series_agg(time_col: str, aggs: ~typing.Dict[str, ~typing.List[str]], windows: ~typing.List[str], group_by: ~typing.List[str], sliding_interval: str, col_formatter: ~typing.Callable[[str, str, int], str] = <function DataFrameAnalyticsFunctions._default_col_formatter>) DataFrame[source]¶
Applies aggregations to the specified columns of the DataFrame over specified time windows, and grouping criteria.
- Parameters:
aggs – A dictionary where keys are column names and values are lists of the desired aggregation functions.
windows – Time windows for aggregations using strings such as ‘7D’ for 7 days, where the units are S: Seconds, M: Minutes, H: Hours, D: Days, W: Weeks, MM: Months, Y: Years. For future-oriented analysis, use positive numbers, and for past-oriented analysis, use negative numbers.
sliding_interval – Interval at which the window slides, specified in the same format as the windows.
group_by – A list of column names on which the DataFrame is partitioned for separate window calculations.
col_formatter – An optional function for formatting output column names, defaulting to the format ‘<input_col>_<agg>_<window>’. This function takes three arguments: ‘input_col’ (str) for the column name, ‘operation’ (str) for the applied operation, and ‘value’ (int) for the window size, and returns a formatted string for the column name.
- Returns:
A Snowflake DataFrame with additional columns corresponding to each specified time window aggregation.
- Raises:
ValueError – If an unsupported value is specified in arguments.
TypeError – If an unsupported type is specified in arguments.
SnowparkSQLException – If an unsupported aggregration is specified.
Example
This function or method is experimental since 1.12.0.