pandas.api.indexers.FixedForwardWindowIndexer

class pandas.api.indexers.FixedForwardWindowIndexer(index_array=None, window_size=0, **kwargs)[source]

Creates window boundaries for fixed-length windows that include the current row.

Examples

>>> df = pd.DataFrame({'B': [0, 1, 2, np.nan, 4]})
>>> df
     B
0  0.0
1  1.0
2  2.0
3  NaN
4  4.0
>>> indexer = pd.api.indexers.FixedForwardWindowIndexer(window_size=2)
>>> df.rolling(window=indexer, min_periods=1).sum()
     B
0  1.0
1  3.0
2  2.0
3  4.0
4  4.0

Methods

get_window_bounds([num_values, min_periods, …])

Computes the bounds of a window.