Open
Description
Originally from #974
For boolean indexing:
da[key]
wherekey
is a boolean labelled array (with any number of dimensions) is made equivalent toda.where(key.reindex_like(ds), drop=True)
. This matches the existing behavior ifkey
is a 1D boolean array. For multi-dimensional arrays, even though the result is now multi-dimensional, this coupled with automatic skipping of NaNs means thatda[key].mean()
gives the same result as in NumPy.da[key] = value
wherekey
is a boolean labelled array can be made equivalent toda = da.where(*align(key.reindex_like(da), value.reindex_like(da)))
(that is, the three argument form ofwhere
).da[key_0, ..., key_n]
where all ofkey_i
are boolean arrays gets handled in the usual way. It is anIndexingError
to supply multiple labelled keys if any of them are not already aligned with as the corresponding index coordinates (and share the same dimension name). If they want alignment, we suggest users simply writeda[key_0 & ... & key_n]
.