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 417412201,MDU6SXNzdWU0MTc0MTIyMDE=,2802,stack renames single dimensions instead of creating a MultiIndex,601177,closed,0,,,3,2019-03-05T17:24:54Z,2021-01-19T16:32:11Z,2021-01-19T16:32:11Z,NONE,,,,"#### Code Sample ```python >>> da = xr.DataArray([0., 1., 2.]) >>> db = da.stack(z=da.dims) >>> db array([0., 1., 2.]) Coordinates: * z (z) int64 0 1 2 >>> db.unstack('z') Traceback (most recent call last): File """", line 1, in db.unstack('z') File ""/usr/lib64/python3.6/site-packages/xarray/core/dataarray.py"", line 1248, in unstack ds = self._to_temp_dataset().unstack(dim) File ""/usr/lib64/python3.6/site-packages/xarray/core/dataset.py"", line 2315, in unstack raise ValueError('cannot unstack a dimension that does not have ' ValueError: cannot unstack a dimension that does not have a MultiIndex ``` #### Problem description `stack` is not consistently creating a `MultiIndex`, but just renames a dimension in case there is just the single dimension to be stacked. This breaks code where the (number of) dimensions are (is) not known in advance. #### Expected Output `stack` should create a `MultiIndex` in all cases and a `stack`/`unstack` sequence should always return the original `DataArray`. #### Output of ``xr.show_versions()``
commit: None python: 3.6.5.final.0 python-bits: 64 OS: Linux OS-release: 4.19.23-gentoo machine: x86_64 processor: Intel(R) Core(TM) i7-2620M CPU @ 2.70GHz byteorder: little LC_ALL: None LANG: nl_BE.UTF-8 LOCALE: nl_BE.UTF-8 xarray: 0.10.8 pandas: 0.19.1 numpy: 1.14.5 scipy: 0.19.1 netCDF4: 1.3.1 h5netcdf: None h5py: 2.9.0 Nio: None zarr: None bottleneck: 1.2.1 cyordereddict: None dask: None distributed: None matplotlib: 2.2.2 cartopy: None seaborn: None setuptools: 40.6.3 pip: 9.0.1 conda: None pytest: 3.10.1 IPython: 5.4.1 sphinx: 1.7.5
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/2802/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue 396457448,MDU6SXNzdWUzOTY0NTc0NDg=,2658,Dataset character coordinates change to object upon use in Dataset,601177,closed,0,,,2,2019-01-07T11:50:41Z,2021-01-13T17:09:05Z,2021-01-13T17:09:05Z,NONE,,,,"#### Code Sample ```python >>> import xarray as xr >>> test = xr.Dataset(coords={'xy': ['x', 'y']}) >>> test Dimensions: (xy: 2) Coordinates: * xy (xy) >> test['test'] = xr.DataArray(np.array([0, 0]), dims=['xy']) >>> test Dimensions: (xy: 2) Coordinates: * xy (xy) object 'x' 'y' # NOTE 'object' dtype Data variables: test (xy) int64 0 0 ``` #### Problem description The coordinate `dtype` changes from ` /usr/lib64/python3.6/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`. from ._conv import register_converters as _register_converters INSTALLED VERSIONS ------------------ commit: None python: 3.6.5.final.0 python-bits: 64 OS: Linux OS-release: 4.14.83-gentoo machine: x86_64 processor: Intel(R) Core(TM) i7-2620M CPU @ 2.70GHz byteorder: little LC_ALL: None LANG: nl_BE.UTF-8 LOCALE: nl_BE.UTF-8 xarray: 0.10.8 pandas: 0.19.1 numpy: 1.14.5 scipy: 0.19.1 netCDF4: 1.3.1 h5netcdf: None h5py: 2.7.1 Nio: None zarr: None bottleneck: 1.2.1 cyordereddict: None dask: None distributed: None matplotlib: 2.2.2 cartopy: None seaborn: None setuptools: 36.7.2 pip: 9.0.1 conda: None pytest: 3.2.2 IPython: 5.4.1 sphinx: 1.7.5 ","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/2658/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue