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-824461333,https://api.github.com/repos/pydata/xarray/issues/1887,824461333,MDEyOklzc3VlQ29tbWVudDgyNDQ2MTMzMw==,1217238,2021-04-22T01:02:32Z,2021-04-22T01:02:32Z,MEMBER,"> 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.","{""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-824460304,https://api.github.com/repos/pydata/xarray/issues/1887,824460304,MDEyOklzc3VlQ29tbWVudDgyNDQ2MDMwNA==,1217238,2021-04-22T00:59:25Z,2021-04-22T00:59:25Z,MEMBER,"> OK great. To confirm, this is what it would look like:
Yes, this looks right to me.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,294241734
https://github.com/pydata/xarray/issues/1887#issuecomment-824329772,https://api.github.com/repos/pydata/xarray/issues/1887,824329772,MDEyOklzc3VlQ29tbWVudDgyNDMyOTc3Mg==,1217238,2021-04-21T20:16:10Z,2021-04-21T20:16:10Z,MEMBER,"> I've been trying to conceptualize why I think the `where` equivalence (the original proposal) is better than the `stack` proposal (the latter).
Here are two reasons why I like the `stack` version:
1. It's more NumPy like -- boolean indexing in NumPy returns a flat array in the same way
2. It doesn't need dtype promotion to handle possibly missing values, so it will have more predictable semantics.
As a side note: one nice feature of using `isel()` for stacking is that it _does not_ create a MultiIndex, which can be expensive. But there's no reason why we necessarily need to do that for `stack()`. I'll open a new issue to discuss adding an optional parameter.
> * I'm not sure how the setitem would work; `da[key] = value`?
To match the semantics of NumPy, `value` would need to have matching dims/coords to those of `da[key]`. In other words, it would also need to be stacked.
> * If someone wants the `stack` result, it's less work to do original -> `where` result -> `stack` result relative to original -> `stack` result -> `where` result; which suggests they're more composable?
I'm not quite sure this is true -- it's the difference between needing to call `stack()` vs `unstack()`.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,294241734
https://github.com/pydata/xarray/issues/1887#issuecomment-823673654,https://api.github.com/repos/pydata/xarray/issues/1887,823673654,MDEyOklzc3VlQ29tbWVudDgyMzY3MzY1NA==,1217238,2021-04-20T23:50:34Z,2021-04-20T23:50:34Z,MEMBER,"It's worth noting that there is at least one other way boolean indexing could work:
- `ds[key]` could work like `ds.stack({key.name: key.dims}).isel({key.name: np.flatnonzero(key.data)})`, except without creating a MultiIndex. Arguably this might be more useful and also more consistent with NumPy itself. It's also more similar to the operation @Hoeze wants in https://github.com/pydata/xarray/issues/5179.
We can't support both with the same syntax, so we have to make a choice here :).
See also the discussion about what `drop_duplicates`/`unique` should do over in https://github.com/pydata/xarray/pull/5089.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,294241734