Closed
Description
Code Sample, a copy-pastable example if possible
import numpy as np
import xarray as xr
da = xr.DataArray(np.arange(np.prod(dims)).reshape(*dims), coords=[('dim0', np.arange(dims[0])), ('dim1', np.arange(dims[0]) + 2)])
daStacked = da.stack(dim0_dim1=['dim0', 'dim1'])
daStacked.rename(dim1='foo')
Problem description
'dim1'
is indeed neither a variable nor a dimension, since the only dimension is now 'dim0_dim1'
. Is there a good reason to limit the possibility to rename to dimensions rather than all coordinates?
Expected Output
ValueError: cannot rename 'dim1' because it is not a variable or dimension in this dataset
Output of xr.show_versions()
INSTALLED VERSIONS
------------------
commit: None
python: 3.6.6.final.0
python-bits: 64
OS: Linux
OS-release: 2.6.32-696.20.1.el6.x86_64
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: fr_FR.UTF-8
LOCALE: fr_FR.UTF-8
xarray: 0.10.8
pandas: 0.23.4
numpy: 1.15.0
scipy: 1.1.0
netCDF4: 1.4.0
h5netcdf: None
h5py: None
Nio: None
zarr: None
bottleneck: 1.2.1
cyordereddict: None
dask: 0.18.2
distributed: None
matplotlib: 2.2.2
cartopy: None
seaborn: None
setuptools: 40.0.0
pip: 18.0
conda: None
pytest: None
IPython: 6.5.0
sphinx: None