pandas.api.indexers.VariableOffsetWindowIndexer#
- classpandas.api.indexers.VariableOffsetWindowIndexer(index_array=None, window_size=0, index=None, offset=None, **kwargs)[source] #
Calculate window boundaries based on a non-fixed offset such as a BusinessDay.
Examples
>>> from pandas.api.indexers import VariableOffsetWindowIndexer >>> df = pd.DataFrame(range(10), index=pd.date_range("2020", periods=10)) >>> offset = pd.offsets.BDay(1) >>> indexer = VariableOffsetWindowIndexer(index=df.index, offset=offset) >>> df 0 2020年01月01日 0 2020年01月02日 1 2020年01月03日 2 2020年01月04日 3 2020年01月05日 4 2020年01月06日 5 2020年01月07日 6 2020年01月08日 7 2020年01月09日 8 2020年01月10日 9 >>> df.rolling(indexer).sum() 0 2020年01月01日 0.0 2020年01月02日 1.0 2020年01月03日 2.0 2020年01月04日 3.0 2020年01月05日 7.0 2020年01月06日 12.0 2020年01月07日 6.0 2020年01月08日 7.0 2020年01月09日 8.0 2020年01月10日 9.0
Methods
get_window_bounds
([num_values, min_periods, ...])Computes the bounds of a window.