feature request: rolling with datetime range · Issue #13327 · pandas-dev/pandas (original) (raw)
Hello everyone,
I would like to submit one very useful addition to rolling, namely the possibility to compute any statistics over a specific time range.
Indeed, my understanding is that rolling(windows=5).mean()
computes, say, the mean over the last five observations.
Instead, it would be very useful to specify something like `rolling(windows=5,type_windows='time_range').mean() to get the rolling mean over the last 5 days.
So if your data starts on January 1 and then the next data point is on Feb 2nd, then the rolling mean for the Feb 2nb point is NA because there was no data on Jan 29, 30, 31, Feb 1, Feb 2.
I believe this would be very useful in settings where data represents trading data, so most of the time the data points are not equidistant in time. Still, you want to compute rolling metrics that are specified over the same delta.
What do you think?
Thanks!