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 https://github.com/pydata/xarray/pull/6889#issuecomment-1227319231,https://api.github.com/repos/pydata/xarray/issues/6889,1227319231,IC_kwDOAMm_X85JJ2e_,19226431,2022-08-25T14:12:55Z,2022-08-25T14:12:55Z,CONTRIBUTOR,"Great, thanks for the nice review @benbovy ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1331855489 https://github.com/pydata/xarray/pull/6889#issuecomment-1226984544,https://api.github.com/repos/pydata/xarray/issues/6889,1226984544,IC_kwDOAMm_X85JIkxg,19226431,2022-08-25T09:02:36Z,2022-08-25T09:02:36Z,CONTRIBUTOR,@benbovy done :),"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1331855489 https://github.com/pydata/xarray/pull/6889#issuecomment-1214867574,https://api.github.com/repos/pydata/xarray/issues/6889,1214867574,IC_kwDOAMm_X85IaWh2,19226431,2022-08-15T10:31:16Z,2022-08-15T10:31:16Z,CONTRIBUTOR,@benbovy I applied your suggestion (+ a small fix) and merged with the up to date main branch. All tests pass. ,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1331855489 https://github.com/pydata/xarray/pull/6889#issuecomment-1211751670,https://api.github.com/repos/pydata/xarray/issues/6889,1211751670,IC_kwDOAMm_X85IOdz2,19226431,2022-08-11T09:32:01Z,2022-08-11T09:32:01Z,CONTRIBUTOR,Thanks @benbovy¸ glad that the proposed fix can help here! ,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1331855489 https://github.com/pydata/xarray/pull/5984#issuecomment-1012384997,https://api.github.com/repos/pydata/xarray/issues/5984,1012384997,IC_kwDOAMm_X848V8Tl,19226431,2022-01-13T18:10:57Z,2022-01-13T18:10:57Z,CONTRIBUTOR,It was a pleasure!,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1052740367 https://github.com/pydata/xarray/issues/5983#issuecomment-969192355,https://api.github.com/repos/pydata/xarray/issues/5983,969192355,IC_kwDOAMm_X845xLOj,19226431,2021-11-15T18:23:57Z,2021-11-15T18:23:57Z,CONTRIBUTOR,"Not sure, but I'd argue to keep the `DataArray`-from-self-construction as I imagine many convenience cases where arrays maybe `DataArray`, numpy arrays or dask arrays, and one wants to ensure a `DataArray` type. Many other packages like pandas/numpy have that. Also the `xarray.Dataset` supports from-self-construction. Perhaps it is better to raise an error when ambiguities occur? Meaning don't allowing to pass `attrs`, `coords` when data is an DataArray... ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1052736383 https://github.com/pydata/xarray/issues/5983#issuecomment-969086661,https://api.github.com/repos/pydata/xarray/issues/5983,969086661,IC_kwDOAMm_X845wxbF,19226431,2021-11-15T16:31:11Z,2021-11-15T16:31:11Z,CONTRIBUTOR,"Ah yes, this is indeed ambiguous. On the other hand, as long it is still supported to create DataArray's from DataArray's they should at least preserve the data format. I need this as I am creating a subclass from the xarray.DataArray (see https://github.com/PyPSA/linopy/blob/8ac34d9fdbddc1fec0c7b4781f3d49e9c5ae064e/linopy/constraints.py#L18). In case I want to convert a lazy DataArray to my custom class the chunked data is directly computed, which seems a bit weird... ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1052736383