rolling_lfit

hhpy.ds.rolling_lfit(x: Union[Sequence[T_co], int, float, str, bytes, None, AbstractSet[T_co]], window: int, df: pandas.core.frame.DataFrame = None, groupby: Union[Sequence[T_co], int, float, str, bytes, None, AbstractSet[T_co]] = None)[source]

Rolling version of lfit: for each row of the DataFrame / Series look at the previous window rows, then perform an lfit and use this value as a prediction for this row. Useful as naive predictor for time series Data.

Parameters:
  • x – Main variable, name of a column in the DataFrame or vector data
  • window – Size of the rolling window, see pandas.Series.rolling [optional]
  • df – Pandas DataFrame containing the data, other objects are implicitly cast to DataFrame

:param groupby:The columns used for grouping, passed to pandas.DataFrame.groupby [optional] :return: pandas Series containing the fitted values