html_url,issue_url,id,node_id,user,created_at,updated_at,author_association,body,reactions,performed_via_github_app,issue
https://github.com/pydata/xarray/issues/1887#issuecomment-824782830,https://api.github.com/repos/pydata/xarray/issues/1887,824782830,MDEyOklzc3VlQ29tbWVudDgyNDc4MjgzMA==,1200058,2021-04-22T12:08:45Z,2021-04-22T12:11:55Z,NONE,"> > Current proposal (""`stack`""), of `da[key]` and with a dimension of `key`'s name (and probably no multiindex):
> > ```python
> > In [86]: da.values[key.values]
> > Out[86]: array([0, 3, 6, 9]) # But the xarray version
> > ```
>
> The part about this new proposal that is most annoying is that the `key` needs a `name`, which we can use to name the new dimension. That's not too hard to do, but it is little annoying -- in practice you would have to write something like `da[key.rename('key_name')]` much of the time to make this work.
IMO, the perfect solution would be masking support.
I.e. `da[key]` would return the same array with an additional variable `da.mask == key`:
```python
In [87]: da[key]
Out[87]:
array([[ 0, , , 3],
[, , 6, ],
[, 9, , ]])
dtype: int
Dimensions without coordinates: a, b
```
Then we could have something like `da[key].stack(new_dim=[""a"", ""b""], dropna=True)`:
```python
In [87]: da[key].stack(new_dim=[""a"", ""b""], dropna=True)
Out[87]:
array([0, 3, 6, 9])
coords{
""a"" (newdim): [0, 0, 1, 2],
""b"" (newdim): [0, 3, 2, 1],
}
Dimensions without coordinates: newdim
```
Here, `dropna=True` would allow avoiding to create the cross-product of `a, b`.
Also, that would avoid all those unnecessary `float` casts for free.","{""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,294241734
https://github.com/pydata/xarray/issues/1887#issuecomment-544693024,https://api.github.com/repos/pydata/xarray/issues/1887,544693024,MDEyOklzc3VlQ29tbWVudDU0NDY5MzAyNA==,1200058,2019-10-21T20:27:14Z,2019-10-21T20:27:14Z,NONE,"Since https://github.com/pydata/xarray/issues/3206 has been implemented now:
Maybe fancy boolean indexing (`da[boolean_mask]`) could return a sparse array as well.","{""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,294241734