Non-Reducing Return Values in Rolling .apply (original) (raw)

related #2813, #4964 (somewhat)

At the moment rolling_apply (et al) the passed function has to return a value (unlike apply which can return a Series and overall return a DataFrame).

If you could pass it a Series you could, for example, do this:

from pandas.core.algorithms import value_counts
s = Series([1, 1, 2, 3, 1, 2, 3, 2, 1])

pd.rolling_apply(s, 3, value_counts)

from the mailing list.