html_url,issue_url,id,node_id,user,created_at,updated_at,author_association,body,reactions,performed_via_github_app,issue
https://github.com/pydata/xarray/issues/6836#issuecomment-1254926860,https://api.github.com/repos/pydata/xarray/issues/6836,1254926860,IC_kwDOAMm_X85KzKoM,19226431,2022-09-22T12:03:52Z,2022-09-22T12:03:52Z,CONTRIBUTOR,"After trying to dig down further into the code, I saw that grouping over levels seems to be broken generally (up-to-date main branch at time of writing), i.e.
```python
import pandas as pd
import numpy as np
import xarray as xr
midx = pd.MultiIndex.from_product([list(""abc""), [0, 1]], names=(""one"", ""two""))
mda = xr.DataArray(np.random.rand(6, 3), [(""x"", midx), (""y"", range(3))])
mda.groupby(""one"").sum()
```
raises:
```python
File "".../xarray/xarray/core/_reductions.py"", line 5055, in sum
return self.reduce(
File "".../xarray/xarray/core/groupby.py"", line 1191, in reduce
return self.map(reduce_array, shortcut=shortcut)
File "".../xarray/xarray/core/groupby.py"", line 1095, in map
return self._combine(applied, shortcut=shortcut)
File "".../xarray/xarray/core/groupby.py"", line 1127, in _combine
index, index_vars = create_default_index_implicit(coord)
File "".../xarray/xarray/core/indexes.py"", line 974, in create_default_index_implicit
index = PandasMultiIndex(array, name)
File "".../xarray/xarray/core/indexes.py"", line 552, in __init__
raise ValueError(
ValueError: conflicting multi-index level name 'one' with dimension 'one'
```
in the function ``create_default_index_implicit``. I am still a bit puzzled how to approach this. Any idea @benbovy?","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1318992926