Skip to content

NumPy reductions don't work with convert / TimeGrouper #1045

Closed
@wesm

Description

@wesm
(1 + returns).convert('BM', how=np.cumprod)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/home/wesm/code/rapidquant/<ipython-input-22-c8b05a51e175> in <module>()
----> 1 (1 + returns).convert('BM', how=np.cumprod)

/home/wesm/code/pandas/pandas/core/generic.pyc in convert(self, rule, method, how, axis, as_index, closed, label)
    176                 how = translate_grouping(how)
    177 
--> 178             result = grouped.agg(how)
    179         else:
    180             # upsampling

/home/wesm/code/pandas/pandas/core/groupby.pyc in agg(self, func, *args, **kwargs)
    245         See docstring for aggregate
    246         """
--> 247         return self.aggregate(func, *args, **kwargs)
    248 
    249     def _iterate_slices(self):

/home/wesm/code/pandas/pandas/core/groupby.pyc in aggregate(self, func_or_funcs, *args, **kwargs)
   1195                 return self._python_agg_general(func_or_funcs, *args, **kwargs)
   1196             except Exception:
-> 1197                 result = self._aggregate_named(func_or_funcs, *args, **kwargs)
   1198 
   1199             index = Index(sorted(result), name=self.grouper.names[0])

/home/wesm/code/pandas/pandas/core/groupby.pyc in _aggregate_named(self, func, *args, **kwargs)
   1266         result = {}
   1267 
-> 1268         for name in self.grouper:
   1269             grp = self.get_group(name)
   1270             grp.name = name

/home/wesm/code/pandas/pandas/core/groupby.pyc in __iter__(self)
    448 
    449     def __iter__(self):
--> 450         return iter(self.indices)
    451 
    452     def numkeys(self):

/home/wesm/code/pandas/pandas/_tseries.so in pandas._tseries.cache_readonly.__get__ (pandas/src/tseries.c:111266)()

/home/wesm/code/pandas/pandas/core/groupby.pyc in indices(self)
    491     @cache_readonly
    492     def indices(self):
--> 493         if len(self.groupings) == 1:
    494             return self.groupings[0].indices
    495         else:

AttributeError: 'TimeGrouper' object has no attribute 'groupings'

(1 + returns).convert('BM', how=np.cumprod)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions