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 783272657,MDU6SXNzdWU3ODMyNzI2NTc=,4791,Assigning non-dimension coordinates does not conserve MultiIndex type,34008825,open,0,,,3,2021-01-11T11:03:00Z,2023-08-23T13:18:15Z,,NONE,,,," **What happened**: Assigning a new non-dimension coordinate of type `MultiIndex` to a `Dataset/DataArray` returns an object that has the new coordinate as type `Object` instead of `MultiIndex`. **What you expected to happen**: Adding a `MultiIndex` as a dimension coordinate to a `Dataset` keeps the type. It should be the same for non-dimension. **Minimal Complete Verifiable Example**: ```python import numpy as np import pandas as pd import xarray as xr ds = xr.Dataset( data_vars={'foo': (['x', 'y'], np.random.rand(2, 2))}, coords={'x': [1, 2], 'y': [1, 2]} ) idx = pd.MultiIndex.from_arrays([['a', 'b'], [5, 6]]) ds.assign_coords({'z': idx}) # Conserves MultiIndex type ds.assign_coords({'z': ('x', idx)}) # Does not conserve MultiIndex type ``` **Anything else we need to know?**: **Environment**:
Output of xr.show_versions() INSTALLED VERSIONS ------------------ commit: None python: 3.7.9 (default, Aug 31 2020, 17:10:11) [MSC v.1916 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: None.None libhdf5: 1.10.4 libnetcdf: 4.7.3 xarray: 0.16.1 pandas: 1.1.3 numpy: 1.19.1 scipy: 1.5.2 netCDF4: 1.5.3 pydap: installed h5netcdf: None h5py: None Nio: None zarr: 2.6.1 cftime: 1.3.0 nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: None dask: 2.30.0 distributed: 2.30.1 matplotlib: 3.3.3 cartopy: 0.18.0 seaborn: 0.11.0 numbagg: None pint: None setuptools: 50.3.0.post20201006 pip: 20.2.4 conda: 4.9.2 pytest: None IPython: 7.18.1 sphinx: 3.2.1
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/4791/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,issue 778863478,MDU6SXNzdWU3Nzg4NjM0Nzg=,4765,Conversions to Pandas objects fail when mixtures of Index and MultiIndex are present,34008825,closed,0,,,3,2021-01-05T10:49:25Z,2021-06-26T18:24:46Z,2021-06-26T18:24:46Z,NONE,,,,"Hello Xarray team. Thank you very much for your efforts, they have made my job more pleasant. **What happened**: When I try to convert a DataArray with a mix of MultiIndex and Index into any pandas object, it returns `NotImplementedError: isna is not defined for MultiIndex`. **What you expected to happen**: If the DataArray contains all simple Index objects or one single MultiIndex, the transformation succeeds. I would expect the same from a mixture. **Minimal Complete Verifiable Example**: ```python import numpy as np import pandas as pd import xarray as xr da = xr.DataArray( np.random.randint(0, 10, size=[3, 3, 3]), coords={'x': ['x1', 'x2', 'x3'], 'y': ['y1', 'y2', 'y3'], 'z': ['z1', 'z2', 'z3']}, dims=['x', 'y', 'z'] ) da.to_series() # This works da.stack(xyz=['x', 'y', 'z']).to_series() # This works da.stack(xy=['x', 'y']).to_series() # This does not work ``` **Anything else we need to know?**: It happens the same thing with DataSet. **Environment**:
Output of xr.show_versions() INSTALLED VERSIONS ------------------ commit: None python: 3.7.9 (default, Aug 31 2020, 17:10:11) [MSC v.1916 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: None.None libhdf5: 1.10.4 libnetcdf: 4.7.3 xarray: 0.16.1 pandas: 1.1.3 numpy: 1.19.1 scipy: 1.5.2 netCDF4: 1.5.3 pydap: installed h5netcdf: None h5py: None Nio: None zarr: None cftime: 1.3.0 nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: None dask: 2.30.0 distributed: 2.30.1 matplotlib: 3.3.3 cartopy: 0.18.0 seaborn: 0.11.0 numbagg: None pint: None setuptools: 50.3.0.post20201006 pip: 20.2.4 conda: 4.9.2 pytest: None IPython: 7.18.1 sphinx: 3.2.1
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/4765/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue