Closed
Description
Just a suggestion - extend rolling
to support a rolling window with a step size, such as R's rollapply(by=X)
.
Code Sample
Pandas - inefficient solution (apply function to every window, then slice to get every second result)
import pandas
ts = pandas.Series(range(0, 40, 2))
ts.rolling(5).apply(max).dropna()[::2]
Suggestion:
ts = pandas.Series(range(0, 40, 2))
ts.rolling(window=5, step=2).apply(max).dropna()
Inspired by R (see rollapply docs):
require(zoo)
TS <- zoo(seq(0, 40, 2))
rollapply(TS, 5, FUN=max, by=2)
8 12 16 20 24 28 32 36 40