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/3546#issuecomment-555537348,https://api.github.com/repos/pydata/xarray/issues/3546,555537348,MDEyOklzc3VlQ29tbWVudDU1NTUzNzM0OA==,6815844,2019-11-19T14:40:01Z,2019-11-19T14:40:01Z,MEMBER,"> This behaviour, however, seems to be slightly different from the .loc API of pandas.DataFrame which can take boolean arrays for selection. Is there a reason for the discrepancy?
Hi, @roxyboy
This is just because that multidimensional boolean indexing is not yet implemented in xarray (#1887).
The one-dimensional indexing would work with `.loc`,
```python
In [2]: da = xr.DataArray([0, 1, 2], dims=['x'])
In [3]: da.loc[da < 1]
Out[3]:
array([0])
Dimensions without coordinates: x
```
FYI, in xarray, probably `.sel` and `.isel` methods are more convenient than `.loc`, as we don't need to remember the dimension order.
For the above (my) example, I would write
```python
da.isel(x=da < 1)
```
instead of `da.loc[da < 1]`.","{""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,524940277
https://github.com/pydata/xarray/issues/3546#issuecomment-555526229,https://api.github.com/repos/pydata/xarray/issues/3546,555526229,MDEyOklzc3VlQ29tbWVudDU1NTUyNjIyOQ==,10194086,2019-11-19T14:15:36Z,2019-11-19T14:15:36Z,MEMBER,"I think `.loc` does not take a boolean array for selection but the actual lon values you want to select. To select with a boolean array you would do:
``` python
sel = da[0, 0] < mask
da[0, 0][sel]
```
If you want to use `.loc` you first need to get the longitude values to select by:
``` python
sel_lon = da[0, 0].lon[sel]
da[0, 0].loc[sel_lon]
```
","{""total_count"": 2, ""+1"": 2, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,524940277