You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using rolling method call on a pandas.core.groupby.DataFrameGroupBy object results in an AttributeError, previous rolling methods are deprecated
#12782
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.
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-35-1ad06da0e074> in <module>()
----> 1 df.groupby(level=['first_name','last_name']).rolling(window=5)#.corr(df['px_last'])
/home/code/anaconda2/lib/python2.7/site-packages/pandas/core/groupby.pyc in __getattr__(self, attr)
482 return self[attr]
483 if hasattr(self.obj, attr):
--> 484 return self._make_wrapper(attr)
485
486 raise AttributeError("%r object has no attribute %r" %
/home/code/anaconda2/lib/python2.7/site-packages/pandas/core/groupby.pyc in _make_wrapper(self, name)
496 "using the 'apply' method".format(kind, name,
497 type(self).__name__))
--> 498 raise AttributeError(msg)
499
500 # need to setup the selection
AttributeError: Cannot access callable attribute 'rolling' of 'DataFrameGroupBy' objects, try using the 'apply' method
Copy and paste runnable code sample
import pandas as pd
import numpy as np
dates = pd.date_range('20130101',periods=6).append(pd.date_range('20130101',periods=6))
df = pd.DataFrame(np.random.randn(12,2),index=dates,columns=list('AB'))
df.groupby(df.index).rolling(window=5)
Expected Output
The code should result in a pandas.core.window.Rolling object.
df.groupby(level=['first_name','last_name'])['column'].apply(pd.rolling_mean, 5) works however according to the documentation this functionality has been deprecated?
Code Sample
df.groupby(level=['first_name','last_name']).rolling(window=5)
Copy and paste runnable code sample
Expected Output
The code should result in a
pandas.core.window.Rolling object
.df.groupby(level=['first_name','last_name'])['column'].apply(pd.rolling_mean, 5)
works however according to the documentation this functionality has been deprecated?output of
pd.show_versions()
The text was updated successfully, but these errors were encountered: