snowflake.snowpark.DataFrameAnalyticsFunctions.compute_lead¶
- DataFrameAnalyticsFunctions.compute_lead(cols: ~typing.List[~typing.Union[str, ~snowflake.snowpark.column.Column]], leads: ~typing.List[int], order_by: ~typing.List[str], group_by: ~typing.List[str], col_formatter: ~typing.Callable[[str, str, int], str] = <function DataFrameAnalyticsFunctions._default_col_formatter>) DataFrame[source]¶
Creates lead columns to the specified columns of the DataFrame by grouping and ordering criteria.
- Parameters:
cols – List of column names or Column objects to calculate lead features.
leads – List of positive integers specifying periods to lead by.
order_by – A list of column names that specify the order in which rows are processed.
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>LEAD<lead>’. This function takes three arguments: ‘input_col’ (str) for the column name, ‘operation’ (str) for the applied operation, and ‘value’ (int) for the lead value, and returns a formatted string for the column name.
- Returns:
A Snowflake DataFrame with additional columns corresponding to each specified lead period.
Example