We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What happened: set_index removes attributes from a coordinate, even with xr.set_options(keep_attrs=True)
xr.set_options(keep_attrs=True)
What you expected to happen: The attributes to be preserved through the coordinate renaming
Minimal Complete Verifiable Example:
import xarray as xr xr.set_options(keep_attrs=True) x = xr.DataArray([1,2], dims=['x']) x.coords['x'] = (['x'],[2,3], {"name":"coord_1"}) x.coords['a'] = (['x'],[0,1], {"name":"coord 2"}) x.set_index(x='a').x.attrs # should be {"name":"coord 2"}, is {}
Environment:
commit: None python: 3.8.5 | packaged by conda-forge | (default, Sep 24 2020, 16:55:52) [GCC 7.5.0] python-bits: 64 OS: Linux OS-release: 3.10.0-1160.11.1.el7.x86_64 machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en.UTF-8 LOCALE: None.None libhdf5: 1.10.6 libnetcdf: 4.7.4
xarray: 0.16.2 pandas: 1.2.0 numpy: 1.19.1 scipy: 1.6.0 netCDF4: 1.5.5.1 pydap: None h5netcdf: 0.8.1 h5py: 3.1.0 Nio: None zarr: None cftime: 1.3.1 nc_time_axis: 1.2.0 PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: 1.3.2 dask: 2021.01.0 distributed: 2021.01.0 matplotlib: 3.3.3 cartopy: 0.18.0 seaborn: 0.11.1 numbagg: None pint: 0.16.1 setuptools: 49.6.0.post20210108 pip: 20.2.3 conda: None pytest: None IPython: 7.18.1 sphinx: 3.4.3
The text was updated successfully, but these errors were encountered:
Did you mean? (Notice the x.x)
x.x
x = x.set_index(x='a') x.x.attrs
I am marking this as a bug.
Sorry, something went wrong.
Yes, my bad
Dataset.set_index
Successfully merging a pull request may close this issue.
What happened: set_index removes attributes from a coordinate, even with
xr.set_options(keep_attrs=True)
What you expected to happen: The attributes to be preserved through the coordinate renaming
Minimal Complete Verifiable Example:
Environment:
Output of xr.show_versions()
INSTALLED VERSIONS
commit: None
python: 3.8.5 | packaged by conda-forge | (default, Sep 24 2020, 16:55:52)
[GCC 7.5.0]
python-bits: 64
OS: Linux
OS-release: 3.10.0-1160.11.1.el7.x86_64
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en.UTF-8
LOCALE: None.None
libhdf5: 1.10.6
libnetcdf: 4.7.4
xarray: 0.16.2
pandas: 1.2.0
numpy: 1.19.1
scipy: 1.6.0
netCDF4: 1.5.5.1
pydap: None
h5netcdf: 0.8.1
h5py: 3.1.0
Nio: None
zarr: None
cftime: 1.3.1
nc_time_axis: 1.2.0
PseudoNetCDF: None
rasterio: None
cfgrib: None
iris: None
bottleneck: 1.3.2
dask: 2021.01.0
distributed: 2021.01.0
matplotlib: 3.3.3
cartopy: 0.18.0
seaborn: 0.11.1
numbagg: None
pint: 0.16.1
setuptools: 49.6.0.post20210108
pip: 20.2.3
conda: None
pytest: None
IPython: 7.18.1
sphinx: 3.4.3
The text was updated successfully, but these errors were encountered: