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
Traceback (most recent call last):
File "t2.py", line 12, in <module>
res = df.groupby(by=[1, 2]).agg({("a", 0): "sum"}) # AttributeError: 'Series' object has no attribute 'columns'
File "/localdisk/dchigare/miniconda3/envs/modin/lib/python3.8/site-packages/pandas/core/groupby/generic.py", line 894, in aggregate
result = op.agg()
File "/localdisk/dchigare/miniconda3/envs/modin/lib/python3.8/site-packages/pandas/core/apply.py", line 169, in aggreturnself.agg_dict_like()
File "/localdisk/dchigare/miniconda3/envs/modin/lib/python3.8/site-packages/pandas/core/apply.py", line 486, in agg_dict_like
results = {
File "/localdisk/dchigare/miniconda3/envs/modin/lib/python3.8/site-packages/pandas/core/apply.py", line 487, in <dictcomp>
key: obj._gotitem(key, ndim=1).agg(how) for key, how in arg.items()
File "/localdisk/dchigare/miniconda3/envs/modin/lib/python3.8/site-packages/pandas/core/groupby/generic.py", line 275, in aggregatereturngetattr(self, func)(*args, **kwargs)
File "/localdisk/dchigare/miniconda3/envs/modin/lib/python3.8/site-packages/pandas/core/groupby/groupby.py", line 2425, in sum
result =self._agg_general(
File "/localdisk/dchigare/miniconda3/envs/modin/lib/python3.8/site-packages/pandas/core/groupby/groupby.py", line 1683, in _agg_general
result =self._cython_agg_general(
File "/localdisk/dchigare/miniconda3/envs/modin/lib/python3.8/site-packages/pandas/core/groupby/groupby.py", line 1743, in _cython_agg_general
numeric_only_bool =self._resolve_numeric_only(how, numeric_only, axis=0)
File "/localdisk/dchigare/miniconda3/envs/modin/lib/python3.8/site-packages/pandas/core/groupby/groupby.py", line 1347, in _resolve_numeric_onlyiflen(obj.columns) andnotlen(check.columns) andnot obj.empty:
File "/localdisk/dchigare/miniconda3/envs/modin/lib/python3.8/site-packages/pandas/core/generic.py", line 5902, in __getattr__returnobject.__getattribute__(self, name)
AttributeError: 'Series' object has no attribute 'columns'
Expected Behavior
Groupby on a frame with duplicated non-MultiIndex values works fine, I would expect the MultiIndex case to work the same.
dchigarev
changed the title
BUG: dictionary groupby aggregation fails in case duplicated MultiIndex values are in columns
BUG: dictionary groupby aggregation fails in case there're duplicated values in MultiIndex columns
Dec 22, 2022
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
Reproducer's traceback
Expected Behavior
Groupby on a frame with duplicated non-MultiIndex values works fine, I would expect the MultiIndex case to work the same.
Installed Versions
INSTALLED VERSIONS
commit : 8dab54d
python : 3.8.13.final.0
python-bits : 64
OS : Linux
OS-release : 5.4.0-124-generic
Version : #140-Ubuntu SMP Thu Aug 4 02:23:37 UTC 2022
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.5.2
numpy : 1.23.3
pytz : 2022.4
dateutil : 2.8.2
setuptools : 65.4.1
pip : 22.2.2
Cython : None
pytest : 7.1.3
hypothesis : None
sphinx : 5.3.0
blosc : None
feather : 0.4.1
xlsxwriter : None
lxml.etree : 4.9.1
html5lib : None
pymysql : None
psycopg2 : 2.9.3
jinja2 : 3.1.2
IPython : 8.4.0
pandas_datareader: None
bs4 : None
bottleneck : None
brotli :
fastparquet : 0.8.3
fsspec : 2022.8.2
gcsfs : None
matplotlib : 3.3.0
numba : None
numexpr : 2.8.3
odfpy : None
openpyxl : 3.0.10
pandas_gbq : 0.17.9
pyarrow : 9.0.0
pyreadstat : None
pyxlsb : None
s3fs : 2022.8.2
scipy : 1.9.1
snappy : None
sqlalchemy : 1.4.41
tables : 3.7.0
tabulate : None
xarray : 2022.9.0
xlrd : 2.0.1
xlwt : None
zstandard : None
tzdata : None
The text was updated successfully, but these errors were encountered: