Skip to main content
`Ctrl`+`K`

# pandas.api.indexers.FixedForwardWindowIndexer

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

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

  This indexer produces forward-looking windows, where each window starts at the current row and extends `window_size` rows ahead, unlike the default backward-looking behavior of `DataFrame.rolling()`.

  Parameters:
    index_array np.ndarray, default None

      Array-like structure representing the indices for the data points. If None, the default indices are assumed. This can be useful for handling non-uniform indices in data, such as in time series with irregular timestamps.

    window_size int, default 0

      Size of the moving window. This is the number of observations used for calculating the statistic. The default is to consider all observations within the window.

    **kwargs

      Additional keyword arguments passed to the subclass’s methods.

  See also

  `DataFrame.rolling`

    Provides rolling window calculations.

  `api.indexers.VariableWindowIndexer`

    Calculate window bounds based on variable-sized windows.

  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.