qis.df_asfreq

qis.df_asfreq(df, freq='QE', method='ffill', fill_na_method='ffill', inclusive=None, include_start_date=False, include_end_date=False, tz=None)[source]

Wrapper to asfreq with closed period.

Reindexes df onto completed calendar boundaries generated at the given frequency. The original start or terminal partial-period observation is included only when explicitly requested.

Parameters:
  • df (DataFrame | Series) – Input time series. Calendar resampling requires a nonempty object to use a DatetimeIndex without NaT; arbitrary indexes remain valid when freq=None.

  • freq (str | None) – pandas frequency string; None returns df unchanged

  • method (Literal['bfill', 'ffill', 'pad']) – fill method passed to pd.DataFrame.reindex()

  • fill_na_method (Literal['bfill', 'ffill', 'pad'] | None) – Fill applied before and after reindexing when the input frequency differs from freq. This lets an exact-boundary missing value use the latest earlier value. Already-periodic input is returned without changing its missing-value mask: on its own grid a missing value is a missing observation, and qis.to_returns and qis.prices_at_freq inherit this rule.

  • inclusive (str | None) – reserved, currently unused

  • include_start_date (bool) – If True, include df’s first observation date.

  • include_end_date (bool) – If True, include df’s last observation date, representing a terminal partial period when it is not a regular boundary.

  • tz (str | None) – timezone string passed to date schedule generation

Raises:
  • TypeError – If calendar resampling is requested for a nonempty object without a DatetimeIndex.

  • ValueError – If calendar resampling is requested for a nonempty object whose index contains NaT.

Return type:

DataFrame | Series

Note

With both inclusion flags false, a history shorter than one complete period returns an empty object with the input schema. Using either flag may produce an irregular index. A df whose index is not in chronological order is sorted before resampling.