id,node_id,number,title,user,state,locked,assignee,milestone,comments,created_at,updated_at,closed_at,author_association,active_lock_reason,draft,pull_request,body,reactions,performed_via_github_app,state_reason,repo,type 1936210577,I_kwDOAMm_X85zaDqR,8292,Different output for Dataset.groupby().mean() depending on whether flox is installed or not,883786,closed,0,,,7,2023-10-10T20:49:52Z,2023-11-24T23:10:42Z,2023-11-24T23:10:42Z,CONTRIBUTOR,,,,"### What happened? We execute `ds.groupby('clifford').mean()`. The resulting `Dataset` is different depending whether the optional package flox is installed or not. ### What did you expect to happen? The result should be the same ### Minimal Complete Verifiable Example ```Python import xarray as xr d={'coords': {'bit_index': {'dims': ('bit_index',), 'attrs': {'name': 'bit_index', 'units': 'a.u.', 'standard_name': 'bit_index', 'long_name': 'bit_index', 'label': 'bit_index'}, 'data': [0, 1]}, 'index': {'dims': ('index',), 'attrs': {'name': 'index', 'units': '', 'standard_name': 'index', 'long_name': 'index', 'label': 'index'}, 'data': [0, 6, 8, 10, 14]}, 'clifford': {'dims': ('index',), 'attrs': {}, 'data': [1, 1, 4, 10, 4]}, 'pauli': {'dims': ('index',), 'attrs': {}, 'data': [12, 12, 6, 12, 6]}, 'pauli_value': {'dims': ('index',), 'attrs': {}, 'data': [1, 1, 1, 1, 1]}}, 'attrs': {}, 'dims': {'bit_index': 2, 'index': 5}, 'data_vars': {'counts': {'dims': ('bit_index', 'index'), 'attrs': {'name': 'counts', 'units': '', 'standard_name': 'Counts', 'long_name': 'Counts', 'label': 'Counts'}, 'data': [[18, 30, 45, 70, 38], [382, 370, 355, 330, 362]]}}} ds=xr.Dataset.from_dict(d) ds.groupby('clifford').mean() ``` (execute with both flox installed and flox not installed) ``` """""" With flox Dimensions: (bit_index: 2, clifford: 3) Coordinates: * bit_index (bit_index) int32 0 1 * clifford (clifford) int64 1 4 10 Data variables: counts (bit_index, clifford) float64 24.0 41.5 70.0 376.0 358.5 330.0 """""" """""" No flox Dimensions: (bit_index: 2, clifford: 3) Coordinates: * bit_index (bit_index) int32 0 1 * clifford (clifford) int64 1 4 10 Data variables: counts (clifford, bit_index) float64 24.0 376.0 41.5 358.5 70.0 330.0 """""" ``` ### MVCE confirmation - [X] Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray. - [X] Complete example — the example is self-contained, including all data and the text of any traceback. - [X] Verifiable example — the example copy & pastes into an IPython prompt or [Binder notebook](https://mybinder.org/v2/gh/pydata/xarray/main?urlpath=lab/tree/doc/examples/blank_template.ipynb), returning the result. - [X] New issue — a search of GitHub Issues suggests this is not a duplicate. - [X] Recent environment — the issue occurs with the latest version of xarray and its dependencies. ### Relevant log output _No response_ ### Anything else we need to know? This is probably related to #7546 ### Environment
INSTALLED VERSIONS ------------------ commit: None python: 3.11.0 (main, Oct 24 2022, 18:26:48) [MSC v.1933 64 bit (AMD64)] python-bits: 64 OS: Windows OS-release: 10 machine: AMD64 processor: Intel64 Family 6 Model 142 Stepping 12, GenuineIntel byteorder: little LC_ALL: None LANG: en LOCALE: ('Dutch_Netherlands', '1252') libhdf5: 1.12.2 libnetcdf: None xarray: 2023.9.0 pandas: 1.5.3 numpy: 1.26.0 scipy: 1.11.3 netCDF4: None pydap: None h5netcdf: 1.2.0 h5py: 3.9.0 Nio: None zarr: None cftime: None nc_time_axis: None PseudoNetCDF: None iris: None bottleneck: None dask: 2023.9.1 distributed: None matplotlib: 3.8.0 cartopy: None seaborn: None numbagg: None fsspec: 2023.9.0 cupy: None pint: 0.22 sparse: None flox: 0.7.2 numpy_groupies: 0.9.22 setuptools: 65.4.1 pip: 23.2 conda: None pytest: 7.4.2 mypy: 1.5.1 IPython: 8.15.0 sphinx: 7.2.6
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/8292/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue 1593602847,I_kwDOAMm_X85e_HMf,7546,DatasetGroupBy.mean discards attributes on coordinate,883786,open,0,,,3,2023-02-21T14:41:37Z,2023-02-21T19:58:18Z,,CONTRIBUTOR,,,,"### What happened? When using `DatasetGroupBy.mean` with the option `keep_attrs=True` the information on the attributes is discarded. Update: this happens when the flox package is _not_ installed. ### What did you expect to happen? The attributes for the grouped coordinate should be in the result ### Minimal Complete Verifiable Example ```Python import xarray as xr import pandas as pd import numpy as np da = xr.DataArray( np.array([1, 2, 3, 1, 2, np.nan]), dims=""time"", coords=dict( time=(""time"", pd.date_range(""01-01-2001"", freq=""M"", periods=6)), labels=(""time"", np.array([""a"", ""b"", ""c"", ""c"", ""b"", ""a""])), ), ) da.labels.attrs['units']='a.u.' ds = xr.Dataset(dict(da=da)) ds.attrs['units']='V' ds m=ds.groupby(""labels"").mean(keep_attrs=True) print(m) # dataset has attribute for units print() print(m.labels) # labels has attribute for units ``` ### MVCE confirmation - [X] Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray. - [X] Complete example — the example is self-contained, including all data and the text of any traceback. - [X] Verifiable example — the example copy & pastes into an IPython prompt or [Binder notebook](https://mybinder.org/v2/gh/pydata/xarray/main?urlpath=lab/tree/doc/examples/blank_template.ipynb), returning the result. - [X] New issue — a search of GitHub Issues suggests this is not a duplicate. ### Relevant log output _No response_ ### Anything else we need to know? _No response_ ### Environment
``` INSTALLED VERSIONS ------------------ commit: None python: 3.10.8 (tags/v3.10.8:aaaf517, Oct 11 2022, 16:50:30) [MSC v.1933 64 bit (AMD64)] python-bits: 64 OS: Windows OS-release: 10 machine: AMD64 processor: Intel64 Family 6 Model 142 Stepping 12, GenuineIntel byteorder: little LC_ALL: None LANG: en LOCALE: ('Dutch_Netherlands', '1252') libhdf5: 1.12.2 libnetcdf: None xarray: 2022.12.0 pandas: 1.5.1 numpy: 1.24.1 scipy: 1.9.2 netCDF4: None pydap: None h5netcdf: 1.0.2 h5py: 3.7.0 Nio: None zarr: None cftime: None nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: None dask: None distributed: None matplotlib: 3.6.2 cartopy: None seaborn: 0.12.1 numbagg: None fsspec: None cupy: None pint: None sparse: None flox: None numpy_groupies: None setuptools: 65.3.0 pip: 22.3.1 conda: None pytest: 7.1.3 mypy: 0.990 IPython: 7.34.0 sphinx: 5.3.0 ```
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/7546/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,issue