Non-Reducing Return Values in Rolling .apply · Issue #4130 · pandas-dev/pandas (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

@hayd

Description

@hayd

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.