home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 904578829

This data as json

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/5727#issuecomment-904578829 https://api.github.com/repos/pydata/xarray/issues/5727 904578829 IC_kwDOAMm_X8416scN 4160723 2021-08-24T12:05:44Z 2021-08-24T12:05:44Z MEMBER

With da.loc[{'x':~mask}], you're actually doing label-based indexing, so ~mask will select repeatedly the items for which x=1.0 (True) and x=0.0 (False):

```python

da.loc[{'x':~mask}] <xarray.DataArray (x: 10)> array([1., 0., 1., 0., 1., 0., 1., 0., 1., 0.]) Coordinates: * x (x) float64 1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0 ```

What you want is integer-based indexing (i.e., not using .loc):

```python

da[{'x':~mask}] <xarray.DataArray (x: 5)> array([0., 2., 4., 6., 8.]) Coordinates: * x (x) float64 0.0 2.0 4.0 6.0 8.0 ```

doc link.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  976207971
Powered by Datasette · Queries took 0.586ms · About: xarray-datasette