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
import xarray as xr da = xr.DataArray(1) da.attrs['foo'] = 'bar' xr.where(da==0, -1, da).attrs # shows: {}
{'foo': 'bar'}
I would expect the attributes to remain in the data array.
commit: None python: 3.8.2 | packaged by conda-forge | (default, Apr 24 2020, 08:20:52) [GCC 7.3.0] python-bits: 64 OS: Linux OS-release: 5.4.0-33-generic machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: en_US.UTF-8 libhdf5: None libnetcdf: None
xarray: 0.15.1 pandas: 1.0.4 numpy: 1.18.4 scipy: 1.4.1 netCDF4: None pydap: None h5netcdf: None h5py: None Nio: None zarr: None cftime: None nc_time_axis: None PseudoNetCDF: None rasterio: 1.1.4 cfgrib: None iris: None bottleneck: None dask: 2.16.0 distributed: None matplotlib: 3.2.1 cartopy: None seaborn: None numbagg: None setuptools: 46.2.0 pip: 20.1 conda: None pytest: None IPython: 7.14.0 sphinx: 3.0.4
The text was updated successfully, but these errors were encountered:
you can work around this by using the where method instead of the global xr.where function:
where
xr.where
In [8]: da.where(da == 0, -1).attrs Out[8]: {'foo': 'bar'}
For more information on the current state of attribute propagation, see #3891.
Sorry, something went wrong.
Thanks a lot @keewis !
reopening so this can be closed by #4687
Successfully merging a pull request may close this issue.
MCVE Code Sample
Expected Output
{'foo': 'bar'}
Problem Description
I would expect the attributes to remain in the data array.
Versions
Output of xr.show_versions()
INSTALLED VERSIONS
commit: None
python: 3.8.2 | packaged by conda-forge | (default, Apr 24 2020, 08:20:52)
[GCC 7.3.0]
python-bits: 64
OS: Linux
OS-release: 5.4.0-33-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
libhdf5: None
libnetcdf: None
xarray: 0.15.1
pandas: 1.0.4
numpy: 1.18.4
scipy: 1.4.1
netCDF4: None
pydap: None
h5netcdf: None
h5py: None
Nio: None
zarr: None
cftime: None
nc_time_axis: None
PseudoNetCDF: None
rasterio: 1.1.4
cfgrib: None
iris: None
bottleneck: None
dask: 2.16.0
distributed: None
matplotlib: 3.2.1
cartopy: None
seaborn: None
numbagg: None
setuptools: 46.2.0
pip: 20.1
conda: None
pytest: None
IPython: 7.14.0
sphinx: 3.0.4
The text was updated successfully, but these errors were encountered: