Adding Timedelta parameter to time-based .rolling() · Issue #15440 · pandas-dev/pandas (original) (raw)

Starting with a simple DataFrame:

n = 10 df = pd.DataFrame({'value': np.arange(n)}, index=pd.date_range('2015-12-24', periods=n, freq="D"))

I can invoke a time-based .rolling() with a string for the offset:

df.rolling('3d').sum()

I would like to invoke it with a Timedelta since it is easier to arithmetically change the window length:

df.rolling(pd.Timedelta(days=3)).sum()