Non-Reducing Return Values in Rolling .apply · Issue #4130 · pandas-dev/pandas (original) (raw)
Navigation Menu
- Explore
- Pricing
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Appearance settings
Description
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.