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

Base class for window bounds calculations.

index_arraynp.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_sizeint, 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.


Additional keyword arguments passed to the subclass’s methods.

See also


Provides rolling window calculations on dataframe.


Provides rolling window calculations on series.


>>> from pandas.api.indexers import BaseIndexer
>>> class CustomIndexer(BaseIndexer):
...     def get_window_bounds(self, num_values, min_periods, center, closed, step):
...         start = np.arange(num_values, dtype=np.int64)
...         end = np.arange(num_values, dtype=np.int64) + self.window_size
...         return start, end
>>> df = pd.DataFrame({"values": range(5)})
>>> indexer = CustomIndexer(window_size=2)
>>> df.rolling(indexer).sum()
0   1.0
1   3.0
2   5.0
3   7.0
4   4.0


get_window_bounds([num_values, min_periods, ...])

Computes the bounds of a window.