Closed
Description
Hello,
I am doing some basic aggregation and boom, some weird bug occurs.
Here is a reprex:
import pandas as pd
import numpy as np
idx2=[pd.to_datetime('2016-08-31 22:08:12.000') ,
pd.to_datetime('2016-08-31 22:09:12.200'),
pd.to_datetime('2016-08-31 22:20:12.400')]
test=pd.DataFrame({'quant':[1.0,1.0,3.0],
'quant2':[1.0,1.0,3.0],
'time2':[pd.to_datetime('2016-08-31 22:08:12.000') ,
pd.to_datetime('2016-08-31 22:09:12.200'),
pd.to_datetime('2016-08-31 22:20:12.400')]},
index=idx2)
test.reset_index(inplace = True)
test
Out[22]:
index quant quant2 time2
0 2016-08-31 22:08:12.000 1.0 1.0 2016-08-31 22:08:12.000
1 2016-08-31 22:09:12.200 1.0 1.0 2016-08-31 22:09:12.200
2 2016-08-31 22:20:12.400 3.0 3.0 2016-08-31 22:20:12.400
df= test.groupby(pd.Grouper(key='time2', freq='1T', closed = 'left', label = 'left'),as_index = False).agg(
{'quant' : 'sum',
'quant2' : 'sum'})
gives
File "<ipython-input-20-c09863316397>", line 19, in <module>
'quant2' : 'sum'})
File "C:\\Anaconda2\lib\site-packages\pandas\core\groupby.py", line 4036, in aggregate
return super(DataFrameGroupBy, self).aggregate(arg, *args, **kwargs)
File "C:\\Anaconda2\lib\site-packages\pandas\core\groupby.py", line 3491, in aggregate
self._insert_inaxis_grouper_inplace(result)
File "C:\\Anaconda2\lib\site-packages\pandas\core\groupby.py", line 4090, in _insert_inaxis_grouper_inplace
self.grouper.get_group_levels(),
File "C:\\Anaconda2\lib\site-packages\pandas\core\groupby.py", line 1911, in get_group_levels
if not self.compressed and len(self.groupings) == 1:
AttributeError: 'BinGrouper' object has no attribute 'compressed'
Is that expected? Why would the as_index = False
generate this error?