home / github

Menu
  • Search all tables
  • GraphQL API

issue_comments

Table actions
  • GraphQL API for issue_comments

2 rows where issue = 976207971 and user = 4160723 sorted by updated_at descending

✎ View and edit SQL

This data as json, CSV (advanced)

Suggested facets: created_at (date), updated_at (date)

user 1

  • benbovy · 2 ✖

issue 1

  • Setting item with loc and boolean mask fails · 2 ✖

author_association 1

  • MEMBER 2
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions performed_via_github_app issue
904642129 https://github.com/pydata/xarray/issues/5727#issuecomment-904642129 https://api.github.com/repos/pydata/xarray/issues/5727 IC_kwDOAMm_X841675R benbovy 4160723 2021-08-24T13:27:20Z 2021-08-24T13:27:20Z MEMBER

I agree that this kind of "boolean indexing" could be clarified a bit in the docs.

I also had to double check here since I use isel() / sel() much more often than [] and .loc[].

Even now, it's not really clear to me why "boolean"-masking should only work with integer-indexing and not label-indexing. Given that the highlighted maybe_cast_to_coords_dtype is the only reason it does not work for label-based indexing.

Hmm you're right. The primary reason of maybe_cast_to_coords_dtype is because pandas indexes don't support floating point values with lower precision than float64 (e.g., #5700). But here https://github.com/pydata/xarray/blob/a6b44d72010c5311fad4f60194b527194e26094b/xarray/core/indexes.py#L236-L237 we actually bypass the underlying pandas index when the labels are a boolean array-like so that boolean indexing should normally work with both integer and label based indexing (#182).

So we should probably fix maybe_cast_to_coords_dtype with something like

python def maybe_cast_to_coords_dtype(label, coords_dtype): label_dtype = np.dtype(getattr(label, "dtype", None)) if coords_dtype.kind == "f" and not isinstance(label, slice) and label_dtype.kind != "b": label = np.asarray(label, dtype=coords_dtype) return label

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Setting item with loc and boolean mask fails 976207971
904578829 https://github.com/pydata/xarray/issues/5727#issuecomment-904578829 https://api.github.com/repos/pydata/xarray/issues/5727 IC_kwDOAMm_X8416scN benbovy 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
}
  Setting item with loc and boolean mask fails 976207971

Advanced export

JSON shape: default, array, newline-delimited, object

CSV options:

CREATE TABLE [issue_comments] (
   [html_url] TEXT,
   [issue_url] TEXT,
   [id] INTEGER PRIMARY KEY,
   [node_id] TEXT,
   [user] INTEGER REFERENCES [users]([id]),
   [created_at] TEXT,
   [updated_at] TEXT,
   [author_association] TEXT,
   [body] TEXT,
   [reactions] TEXT,
   [performed_via_github_app] TEXT,
   [issue] INTEGER REFERENCES [issues]([id])
);
CREATE INDEX [idx_issue_comments_issue]
    ON [issue_comments] ([issue]);
CREATE INDEX [idx_issue_comments_user]
    ON [issue_comments] ([user]);
Powered by Datasette · Queries took 20.749ms · About: xarray-datasette