You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Problem
When I perform simple operations (e.g., +, -, *, /) on DataArray objects, I expected compatible attributes to be maintained, and incompatible attributes to be removed. Even when playing with the available options for keep_attrs, this behavior does not occur. See also #4763 and #2582.
Here is an example showing what happens in each case:
That is to say, I want attributes with conflicting values to be discarded, and all other attributes to be maintained.
Suggested Fix
This is similar to the "drop_conflicts" option for merging attrs, from xarray.merge. I suggest that "drop_conflicts" be added as an option for keep_attrs. For example, I would like to be able to do:
Thanks for opening your first issue here at xarray! Be sure to follow the issue template!
If you have an idea for a solution, we would really welcome a Pull Request with proposed changes.
See the Contributing Guide for more.
It may take us a while to respond here, but we really value your contribution. Contributors like you help make xarray better.
Thank you!
What is your issue?
The Problem
When I perform simple operations (e.g.,
+, -, *, /
) on DataArray objects, I expected compatible attributes to be maintained, and incompatible attributes to be removed. Even when playing with the available options forkeep_attrs
, this behavior does not occur. See also #4763 and #2582.Here is an example showing what happens in each case:
Desired behavior:
That is to say, I want attributes with conflicting values to be discarded, and all other attributes to be maintained.
Suggested Fix
This is similar to the "drop_conflicts" option for merging attrs, from xarray.merge. I suggest that "drop_conflicts" be added as an option for
keep_attrs
. For example, I would like to be able to do:If anyone else is able to add this option into the code, that would be amazing!
Or, if there is already a way to accomplish this behavior, I would appreciate any advice on how to do it.
Output of
xr.show_versions()
xarray: 2023.8.0
pandas: 1.4.4
numpy: 1.21.5
scipy: 1.9.1
netCDF4: None
pydap: None
h5netcdf: None
h5py: 3.7.0
Nio: None
zarr: 2.13.6
cftime: None
nc_time_axis: None
PseudoNetCDF: None
iris: None
bottleneck: 1.3.5
dask: 2022.7.0
distributed: 2022.7.0
matplotlib: 3.5.2
cartopy: None
seaborn: 0.11.2
numbagg: None
fsspec: 2022.7.1
cupy: None
pint: None
sparse: None
flox: None
numpy_groupies: None
setuptools: 63.4.1
pip: 22.2.2
conda: 22.9.0
pytest: 7.1.2
mypy: None
IPython: 7.31.1
sphinx: 5.0.2
The text was updated successfully, but these errors were encountered: