Skip to main content
`Ctrl`+`K`

# pandas.api.indexers.VariableOffsetWindowIndexer

class pandas.api.indexers.VariableOffsetWindowIndexer(index_array=None, window_size=0, index=None, offset=None, **kwargs)

  Calculate window boundaries based on a non-fixed offset such as a BusinessDay.

  Parameters:
    index_array np.ndarray, default 0

      Array-like structure specifying the indices for data points. This parameter is currently not used.

    window_size int, optional, default 0

      Specifies the number of data points in each window. This parameter is currently not used.

    index DatetimeIndex, optional

      `DatetimeIndex` of the labels of each observation.

    offset BaseOffset, optional

      `DateOffset` representing the size of the window.

    **kwargs

      Additional keyword arguments passed to the parent class `BaseIndexer`.

  See also

  `api.indexers.BaseIndexer`

    Base class for all indexers.

  `DataFrame.rolling`

    Rolling window calculations on DataFrames.

  `offsets`

    Module providing various time offset classes.

  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.