-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
ENH/API: rolling_apply to pass frames to the rolled function (rather than ndarrays) #5071
Comments
+1 I was just trying to do similar. Would be nice if rolling_apply, expanding_apply had an option to work over the whole DataFrame. It doesn't even have to pass frames, but rather just roll over the whole 0 axis instead of one series at a time. |
That sounds equivalent to the split-apply(-combine) approach of groupby, only pandas doesn't related #4059 |
Just ran into the same issue. |
same issue here |
@jreback What's the best way to do this? If I try and change the ...
return _zsqrt(algos.roll_var(arg, window, minp, ddof))
TypeError: Argument 'input' has incorrect type (expected numpy.ndarray, got Series) Could this be done in |
So just to have an example
The issue is that you need to pass a constructed object to |
Is this do-able with In [28]: series=pd.Series(range(10),dtype='float64')
In [29]: roll_generic(series, win=2, minp=2, offset=0, func=lambda x: x.sum(), args=[], kwargs={})
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-29-3ec0f9465dad> in <module>()
----> 1 roll_generic(series, win=2, minp=2, offset=0, func=lambda x: x.sum(), args=[], kwargs={})
TypeError: Argument 'input' has incorrect type (expected numpy.ndarray, got Series) Does that mean we need a parallel function which operates on I could imagine having a function that generated the groups - then it would actually be a groupby. But haven't thought through it enough and performance may be an issue. |
no u have to change roll_generic to take an object doing with GroupBy is a whole separate idea - I may do that but it's orthogonal (and the reason is different than this) |
OK, I haven't worked with Cython before, and not sure how it handles non-numpy arrays, but I can have a go. Probably won't have immediate results. |
Almost 3 years and it's still an issue :'(
`AttributeError Traceback (most recent call last) /usr/local/lib/python2.7/dist-packages/pandas/core/generic.pyc in getattr(self, name) AttributeError: 'DataFrame' object has no attribute 'rolling' OR AttributeError Traceback (most recent call last) /usr/local/lib/python2.7/dist-packages/pandas/core/window.pyc in apply(self, func, args, kwargs) /usr/local/lib/python2.7/dist-packages/pandas/core/window.pyc in apply(self, func, args, kwargs) /usr/local/lib/python2.7/dist-packages/pandas/core/window.pyc in _apply(self, func, name, window, center, check_minp, how, **kwargs) /usr/local/lib/python2.7/dist-packages/numpy/lib/shape_base.pyc in apply_along_axis(func1d, axis, arr, _args, *_kwargs) /usr/local/lib/python2.7/dist-packages/pandas/core/window.pyc in calc(x) /usr/local/lib/python2.7/dist-packages/pandas/core/window.pyc in f(arg, window, min_periods) pandas/algos.pyx in pandas.algos.roll_generic (pandas/algos.c:51577)() in test_distance_sum(df) AttributeError: 'numpy.ndarray' object has no attribute 'ix' |
Returning a Series: http://stackoverflow.com/questions/19121854/using-rolling-apply-on-a-dataframe-object
Returning a Scalar: http://stackoverflow.com/questions/21040766/python-pandas-rolling-apply-two-column-input-into-function/21045831#21045831
The text was updated successfully, but these errors were encountered: