Description
It seems like set_coords()
doesn't create an index variable. Is there a reason for this? I was surprised that the following code snippets produce different Datasets (first one has empty indexes
, second one has x
in indexes
), even though both Datasets have a 'dimension coordinate' x
:
(1)
import numpy as np
import xarray as xr
ds = xr.Dataset()
ds['a'] = ('x', np.linspace(0,1))
ds['b'] = ('x', np.linspace(3,4))
ds = ds.rename(b='x')
ds = ds.set_coords('x')
print(ds)
print('indexes', ds.indexes)
(2)
import numpy as np
import xarray as xr
ds = xr.Dataset()
ds['a'] = ('x', np.linspace(0,1))
ds['x'] = ('x', np.linspace(3,4))
print(ds)
print('indexes', ds.indexes)
Environment:
Output of xr.show_versions()
INSTALLED VERSIONS
commit: None
python: 3.7.6 | packaged by conda-forge | (default, Jun 1 2020, 18:57:50)
[GCC 7.5.0]
python-bits: 64
OS: Linux
OS-release: 5.4.0-47-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_GB.UTF-8
LOCALE: en_GB.UTF-8
libhdf5: 1.10.5
libnetcdf: 4.7.4
xarray: 0.16.0
pandas: 1.1.1
numpy: 1.18.5
scipy: 1.4.1
netCDF4: 1.5.3
pydap: None
h5netcdf: None
h5py: 2.10.0
Nio: None
zarr: None
cftime: 1.2.1
nc_time_axis: None
PseudoNetCDF: None
rasterio: None
cfgrib: None
iris: None
bottleneck: None
dask: 2.23.0
distributed: 2.25.0
matplotlib: 3.2.2
cartopy: None
seaborn: None
numbagg: None
pint: 0.13
setuptools: 49.6.0.post20200814
pip: 20.2.3
conda: 4.8.4
pytest: 5.4.3
IPython: 7.15.0
sphinx: 3.2.1