Open chris-b1 opened 8 years ago
ok will have to add here https://github.com/pydata/pandas/issues/12871
@jreback @chris-b1 I get the following exception using mentioned example. Can you please update the description of issue?
pd.show_versions()
In [1]: df.groupby(pd.Grouper(key='date', freq='2D')).sum()
---------------------------------------------------------------------------
NotImplementedError Traceback (most recent call last)
/Users/discort/python/fun/pandas/pandas/tests/test_resample.py in <module>()
----> 1 df.groupby(pd.Grouper(key='date', freq='2D')).sum()
/Users/discort/python/fun/pandas/pandas/core/generic.py in groupby(self, by, axis, level, as_index, sort, group_keys, squeeze, observed, **kwargs)
6996 return groupby(self, by=by, axis=axis, level=level, as_index=as_index,
6997 sort=sort, group_keys=group_keys, squeeze=squeeze,
-> 6998 observed=observed, **kwargs)
6999
7000 def asfreq(self, freq, method=None, how=None, normalize=False,
/Users/discort/python/fun/pandas/pandas/core/groupby/groupby.py in groupby(obj, by, **kwds)
1964 raise TypeError('invalid type: %s' % type(obj))
1965
-> 1966 return klass(obj, by, **kwds)
/Users/discort/python/fun/pandas/pandas/core/groupby/groupby.py in __init__(self, obj, keys, axis, level, grouper, exclusions, selection, as_index, sort, group_keys, squeeze, observed, **kwargs)
363 sort=sort,
364 observed=observed,
--> 365 mutated=self.mutated)
366
367 self.obj = obj
/Users/discort/python/fun/pandas/pandas/core/groupby/grouper.py in _get_grouper(obj, key, axis, level, sort, observed, mutated, validate)
478 # a passed-in Grouper, directly convert
479 if isinstance(key, Grouper):
--> 480 binner, grouper, obj = key._get_grouper(obj, validate=False)
481 if key.key is None:
482 return grouper, [], obj
/Users/discort/python/fun/pandas/pandas/core/resample.py in _get_grouper(self, obj, validate)
1317 def _get_grouper(self, obj, validate=True):
1318 # create the resampler and return our binner
-> 1319 r = self._get_resampler(obj)
1320 r._set_binner()
1321 return r.binner, r.grouper, r.obj
/Users/discort/python/fun/pandas/pandas/core/resample.py in _get_resampler(self, obj, kind)
1305 groupby=self,
1306 kind=kind,
-> 1307 axis=self.axis)
1308 elif isinstance(ax, TimedeltaIndex):
1309 return TimedeltaIndexResampler(obj,
/Users/discort/python/fun/pandas/pandas/core/resample.py in __init__(self, obj, groupby, axis, kind, **kwargs)
78
79 if self.groupby is not None:
---> 80 self.groupby._set_grouper(self._convert_obj(obj), sort=True)
81
82 def __unicode__(self):
/Users/discort/python/fun/pandas/pandas/core/resample.py in _convert_obj(self, obj)
1050 " with a PeriodIndex is not currently supported,"
1051 " use .set_index(...) to explicitly set index")
-> 1052 raise NotImplementedError(msg)
1053
1054 if self.loffset is not None:
NotImplementedError: Resampling from level= or on= selection with a PeriodIndex is not currently supported, use .set_index(...) to explicitly set index
I am receiving this error also, even when I set the convention parameter.
dfm_ltv.set_index("date").groupby([pd.Grouper(key='country'),
pd.Grouper(key='team'),
pd.Grouper(freq="s", level="date", convention="start")]).sum()
---
NotImplementedError: Resampling from level= or on= selection with a PeriodIndex is not currently supported, use .set_index(...) to explicitly set index
Output of pd.show_version():
xref #13961