home / github

Menu
  • GraphQL API
  • Search all tables

issue_comments

Table actions
  • GraphQL API for issue_comments

3 rows where issue = 1319724885 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 · 3 ✖

issue 1

  • sel by slice not working for multi-index containing float-values · 3 ✖

author_association 1

  • MEMBER 3
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions performed_via_github_app issue
1239509767 https://github.com/pydata/xarray/issues/6838#issuecomment-1239509767 https://api.github.com/repos/pydata/xarray/issues/6838 IC_kwDOAMm_X85J4WsH benbovy 4160723 2022-09-07T15:02:12Z 2022-09-07T15:02:12Z MEMBER

@nunupeke The TypeError in your example should be fixed in #7004, which also improves how slice objects are handled in general for a multi-index.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  sel by slice not working for multi-index containing float-values 1319724885
1239412326 https://github.com/pydata/xarray/issues/6838#issuecomment-1239412326 https://api.github.com/repos/pydata/xarray/issues/6838 IC_kwDOAMm_X85J3-5m benbovy 4160723 2022-09-07T13:45:25Z 2022-09-07T13:45:25Z MEMBER

only that the resulting coordinates look a bit weird, containing slices

I'm working on this issue right now and I see this too.

I don't think that providing slice objects to multi-index level coordinates in .sel() is something that so far we've really expected to work. We rather expect scalar values, and we explicitly raise a ValueError when trying to pass multiple values:

```python da

<xarray.DataArray (x: 4)>

array([0.30120807, 0.43951659, 0.19163508, 0.57251755])

Coordinates:

* x (x) object MultiIndex

* y (x) float64 0.0 0.3333 0.6667 1.0

* z (x) int64 4 5 6 7

da.sel(z=[4, 5])

ValueError: Vectorized selection is not available along coordinate 'z' (multi-index level)

```

The fact that it used to work with slices looks like a side effect. For example, providing a slice for only one of the level coordinates drops that coordinate in the resulting dataset (v2022.3.0):

```python da.sel(y=slice(None, 0.5))

<xarray.DataArray (z: 2)>

array([0.4004091 , 0.11179854])

Coordinates:

* z (z) int64 4 5

The 'y' coord is missing! It should be still there.

```

I think that we could support slices in a clean way (maybe any sequence of values too?) by reusing pandas.MultiIndex.get_locs() internally. However, in that case it would be hard to automatically collapse one or more multi-index levels, e.g.,

```python

note the difference between

da.sel(y=0.0, z=slice(None))

<xarray.DataArray (x: 1)>

array([0.08696024])

Coordinates:

* x (x) object MultiIndex

* y (x) float64 0.0

* z (x) int64 4

and

da.sel(y=0.0)

<xarray.DataArray (z: 1)>

array([0.08696024])

Coordinates:

* z (z) int64 4

y float64 0.0

the 1st one calls pandas.MultiIndex.get_locs, while

the 2nd one calls pandas.MultiIndex.get_loc_level

```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  sel by slice not working for multi-index containing float-values 1319724885
1199204456 https://github.com/pydata/xarray/issues/6838#issuecomment-1199204456 https://api.github.com/repos/pydata/xarray/issues/6838 IC_kwDOAMm_X85Hemho benbovy 4160723 2022-07-29T12:11:23Z 2022-07-29T12:11:23Z MEMBER

Thanks for the report @nunupeke. That's definitely a regression. I'm not that surprised actually as the logic behind .sel() is already quite convoluted for the case of (pandas) multi-indexes :-).

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  sel by slice not working for multi-index containing float-values 1319724885

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 33.567ms · About: xarray-datasette