Skip to content

apply_smoothing API Reference

geoloop.utils.helpers.apply_smoothing

apply_smoothing(
    df: DataFrame,
    column: str,
    smoothing: int | str | None = None,
    outdir: Path | None = None,
    prefix: str = "data",
) -> pd.DataFrame

Apply smoothing to a timeseries column in a dataframe.

Parameters:

Name Type Description Default
df DataFrame

Input dataframe (must contain column, may contain local_time).

required
column str

Column name to smooth (e.g. "m_flow" or "Q").

required
smoothing int | str | None
  • int: rolling average window (in samples, e.g. hours).
  • "D": daily average (requires local_time).
  • "M": monthly average (requires local_time).
  • "none" or None: no smoothing.
None
outdir Path

Directory to save smoothed CSV (for "D" or "M").

None
prefix str

Prefix for the output filename ("flow" or "load").

'data'

Returns:

Type Description
DataFrame

DataFrame with smoothed column.

Raises:

Type Description
ValueError

If smoothing is "D" or "M" and local_time column is missing. If smoothing is an unsupported string.