pandas.api.indexers.VariableOffsetWindowIndexer # pandas.api.indexers类 。VariableOffsetWindowIndexer ( index_array = None , window_size = 0 , index = None , offset = None , ** kwargs ) [来源] # 根据非固定偏移(例如 BusinessDay)计算窗口边界。 例子 >>> 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 方法 get_window_bounds([num_values, min_periods, ...]) 计算窗口的边界。