augment_leads

augment_leads(
    data,
    date_column,
    value_column,
    leads=1,
    reduce_memory=False,
    engine='auto',
)

Adds lead columns to a pandas or polars DataFrame (or grouped DataFrame).

Parameters

Name Type Description Default
data DataFrame or GroupBy(pandas or polars) Input tabular data to augment. required
date_column str or ColumnSelector Name of the date column used to determine ordering prior to shifting. Accepts tidy selectors for convenience. required
value_column str, ColumnSelector, or list One or more column names/tidy selectors whose lead values will be appended. required
leads int, tuple, list, or str Lead specification. Accepts: - int: single lead value - tuple(start, end): inclusive range of leads - list[int] or list[str]: explicit values/durations - str: duration (e.g., "3 days") converted using date_column 1
reduce_memory bool If True, attempts to reduce memory usage (pandas only). False
engine (auto, pandas, polars, cudf) Execution engine. When β€œauto” (default) the backend is inferred from the input data type. "auto"

Returns

Name Type Description
DataFrame DataFrame with lead columns appended. The return type matches the input backend.