df = pd.DataFrame({'grp': [0, 0, 1, 1], 'returns': [0, 0.1, -.1, .1]})
df.groupby('grp').returns.compound()
df.groupby('grp').returns.apply('compound')
Doesn't seem to work:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-193-cb3ce32c6c2e> in <module>()
1 df = pd.DataFrame({'grp': [0, 0, 1, 1], 'returns': [0, 0.1, -.1, .1]})
----> 2 df.groupby('grp').returns.compound()
3 df.groupby('grp').returns.apply('compound')
/home/wiecki/envs/zipline_p14/lib/python2.7/site-packages/pandas/core/groupby.py in __getattr__(self, attr)
481 return self[attr]
482 if hasattr(self.obj, attr):
--> 483 return self._make_wrapper(attr)
484
485 raise AttributeError("%r object has no attribute %r" %
/home/wiecki/envs/zipline_p14/lib/python2.7/site-packages/pandas/core/groupby.py 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 'compound' of 'SeriesGroupBy' objects, try using the 'apply' method
apply also doesn't work.
This is with pandas 0.14.
Comment From: jreback
use .apply(lamba x: x.compound ())
Comment From: twiecki
ok, but I think it'd be nice if these could be used directly in a groupby.
Comment From: jreback
needs to be added to the whitelist
want to submit a pull-request?
Comment From: twiecki
Sure, can you point me to it?
Comment From: jreback
https://github.com/pydata/pandas/blob/master/pandas/core/groupby.py#L69
their is a test as well
Comment From: jreback
deprecating .compound()
on a DataFrame
so this is out of scope