-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Non-Reducing Return Values in Rolling .apply #4130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Here's the example, only issue is that you need to test first iteration to see what structure is returned
|
A series can be produced now via the keyword argument >>>
s.rolling(3).apply(lambda x: x[:2], raw=False)
TypeError: cannot convert the series to <class 'float'> Not sure it is even feasible to support non-reducing functions like |
Looks like there hasn't been a lot of demand for this feature and would increase the complexity greatly if apply could return arbitrary shaped results for each window, so closing for now. Can reopen if there's more interest |
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 the mailing list.
The text was updated successfully, but these errors were encountered: