home / github

Menu
  • GraphQL API
  • Search all tables

issue_comments

Table actions
  • GraphQL API for issue_comments

6 rows where issue = 564555854 sorted by updated_at descending

✎ View and edit SQL

This data as json, CSV (advanced)

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

user 4

  • max-sixty 2
  • ivirshup 2
  • shoyer 1
  • dcherian 1

author_association 2

  • MEMBER 4
  • NONE 2

issue 1

  • Pointwise indexing · 6 ✖
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions performed_via_github_app issue
586123705 https://github.com/pydata/xarray/issues/3768#issuecomment-586123705 https://api.github.com/repos/pydata/xarray/issues/3768 MDEyOklzc3VlQ29tbWVudDU4NjEyMzcwNQ== shoyer 1217238 2020-02-14T06:52:27Z 2020-02-14T06:52:27Z MEMBER

The model of how indexing with non-DataArray objects is described here under vectorized indexing: “Slices or sequences/arrays without named-dimensions are treated as if they have the same dimension which is indexed along”

For better or worse, xarray doesn’t have any way to distinguish between “meaningful” and “default” dimension names. This means that a DataArray without explicitly named dimensions will indeed broadcast differently (e.g., in either arithmetic or indexing) than unlabeled NumPy arrays.

These were intentional design choices: we like our name based broadcasting rules better than NumPy’s positional rules. And for the most part, the default dimension names like dim_0 are just there so a user can see how they need to change their data instead of getting an error message.

{
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Pointwise indexing 564555854
586099185 https://github.com/pydata/xarray/issues/3768#issuecomment-586099185 https://api.github.com/repos/pydata/xarray/issues/3768 MDEyOklzc3VlQ29tbWVudDU4NjA5OTE4NQ== max-sixty 5635139 2020-02-14T05:01:56Z 2020-02-14T05:02:33Z MEMBER

Thanks for the clear question.

Having array and xr.DataArray(array) behave differently as arguments is (fairly) rare, so I can understand that it might be surprising at first.

One advantage of this is it allowing pointwise indexing over a new dimension. Generally that would be a usefully named dimension (e.g. z in the docs), rather than dim_0 though...

I'll defer to @shoyer on commenting on his design choices if he sees this thread

I do think it's complicated though (I find myself re-reading the docs and trying to remember how it works depending on the type & order of the arguments!), and a nicely presented table with the possible indexing methods and their results would be great.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Pointwise indexing 564555854
586078165 https://github.com/pydata/xarray/issues/3768#issuecomment-586078165 https://api.github.com/repos/pydata/xarray/issues/3768 MDEyOklzc3VlQ29tbWVudDU4NjA3ODE2NQ== ivirshup 8238804 2020-02-14T03:15:47Z 2020-02-14T03:15:47Z NONE

Why do DataArrays have different behavior than other array-likes for these methods?

For sel and isel. What the reasoning for making these statements behave differently?

Setup ```python import xarray as xr import numpy as np da = xr.DataArray( np.arange(56).reshape((7, 8)), coords={ 'x': list('abcdefg'), 'y': 10 * np.arange(8) }, dims=['x', 'y'] ) ```

```python xidx = np.array([1, 2, 3]) yidx = np.array([1, 2, 3])

da.isel(x=xidx, y=yidx)

<xarray.DataArray (x: 3, y: 3)>

array([[ 9, 10, 11],

[17, 18, 19],

[25, 26, 27]])

Coordinates:

* x (x) <U1 'b' 'c' 'd'

* y (y) int64 10 20 30

da.isel(x=xr.DataArray(xidx), y=xr.DataArray(yidx))

<xarray.DataArray (dim_0: 3)>

array([ 9, 18, 27])

Coordinates:

x (dim_0) <U1 'b' 'c' 'd'

y (dim_0) int64 10 20 30

Dimensions without coordinates: dim_0

```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Pointwise indexing 564555854
586073334 https://github.com/pydata/xarray/issues/3768#issuecomment-586073334 https://api.github.com/repos/pydata/xarray/issues/3768 MDEyOklzc3VlQ29tbWVudDU4NjA3MzMzNA== max-sixty 5635139 2020-02-14T02:54:31Z 2020-02-14T02:54:31Z MEMBER

Why do DataArrays have different behavior than other array-likes for these methods?

Could you expand a bit? Do you mean re sel etc rather than positional indexing?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Pointwise indexing 564555854
586072916 https://github.com/pydata/xarray/issues/3768#issuecomment-586072916 https://api.github.com/repos/pydata/xarray/issues/3768 MDEyOklzc3VlQ29tbWVudDU4NjA3MjkxNg== ivirshup 8238804 2020-02-14T02:52:34Z 2020-02-14T02:52:34Z NONE

The documentation for what you want is here: https://xarray.pydata.org/en/stable/indexing.html#more-advanced-indexing. Basically you need to provide DataArrays with a new dimension instead of lists.

Thanks! I must have missed this, I suspect since my use was actually setting the values at some coordinates. Is there an efficient way to do that?

I'd be happy to add some notes to the documentation about that. The .sel and isel methods could definitely use longer doc strings. It would be useful to have a better understanding of the concept this implements though. Why do DataArrays have different behavior than other array-likes for these methods?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Pointwise indexing 564555854
585820745 https://github.com/pydata/xarray/issues/3768#issuecomment-585820745 https://api.github.com/repos/pydata/xarray/issues/3768 MDEyOklzc3VlQ29tbWVudDU4NTgyMDc0NQ== dcherian 2448579 2020-02-13T15:38:56Z 2020-02-13T15:38:56Z MEMBER

The documentation for what you want is here: https://xarray.pydata.org/en/stable/indexing.html#more-advanced-indexing. Basically you need to provide DataArrays with a new dimension instead of lists.

PRs to improve the documentation are very welcome (ref https://github.com/pydata/xarray/issues/1552). We actually have a nice schematic here: https://xarray.pydata.org/en/stable/interpolation.html#advanced-interpolation

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Pointwise indexing 564555854

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