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
Consider the following 4 ways to mask an DataArray:
importxarrayasxrds=xr.Dataset({'a': (['x'], range(10))},
coords={'x': range(10)})
ds['msk']=ds.a>5msk=ds.a>5v1=ds.a.where(ds.a>5)
v2=ds.a.where(msk)
v3=ds.where(ds.msk).av4=ds.a.where(ds.msk)
', '.join(str(v.name) forvin (v1, v2, v3, v4))```#output:'a, a, a, None'
Problem description
All vs defined above are identical, except that v4 has lost its name in masking. This can cause errors in merging (like just happened to me and was hard and annoying to catch).
Is this behavior intentional? It seems inconsistent to me that ds.a.where(ds.msk) is not equivalent to ds.where(ds.msk).a
Expected Output
I would expect ds.a.where(ds.msk) to return a DataArray with the name a.
Uh oh!
There was an error while loading. Please reload this page.
Code Sample, a copy-pastable example if possible
Consider the following 4 ways to mask an
DataArray
:Problem description
All
v
s defined above are identical, except thatv4
has lost its name in masking. This can cause errors in merging (like just happened to me and was hard and annoying to catch).Is this behavior intentional? It seems inconsistent to me that
ds.a.where(ds.msk)
is not equivalent tods.where(ds.msk).a
Expected Output
I would expect
ds.a.where(ds.msk)
to return aDataArray
with the namea
.Output of
xr.show_versions()
xarray: 0.11.1+49.g27cf53f2
pandas: 0.23.3
numpy: 1.16.0
scipy: 1.2.0
netCDF4: None
pydap: None
h5netcdf: None
h5py: None
Nio: None
zarr: 2.2.0
cftime: 1.0.3.4
PseudonetCDF: None
rasterio: None
cfgrib: None
iris: None
bottleneck: 1.2.1
cyordereddict: None
dask: 1.1.0
distributed: 1.25.3
matplotlib: 3.0.2
cartopy: 0.17.0
seaborn: 0.9.0
setuptools: 40.8.0
pip: 19.0.1
conda: None
pytest: None
IPython: 7.2.0
sphinx: 1.8.2
The text was updated successfully, but these errors were encountered: