home / github

Menu
  • Search all tables
  • GraphQL API

issue_comments

Table actions
  • GraphQL API for issue_comments

4 rows where author_association = "MEMBER", issue = 294241734 and user = 1217238 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 1

  • shoyer · 4 ✖

issue 1

  • Boolean indexing with multi-dimensional key arrays · 4 ✖

author_association 1

  • MEMBER · 4 ✖
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions performed_via_github_app issue
824461333 https://github.com/pydata/xarray/issues/1887#issuecomment-824461333 https://api.github.com/repos/pydata/xarray/issues/1887 MDEyOklzc3VlQ29tbWVudDgyNDQ2MTMzMw== shoyer 1217238 2021-04-22T01:02:32Z 2021-04-22T01:02:32Z MEMBER

Current proposal ("stack"), of da[key] and with a dimension of key's name (and probably no multiindex):

python In [86]: da.values[key.values] Out[86]: array([0, 3, 6, 9]) # But the xarray version

The part about this new proposal that is most annoying is that the key needs a name, which we can use to name the new dimension. That's not too hard to do, but it is little annoying -- in practice you would have to write something like da[key.rename('key_name')] much of the time to make this work.

{
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Boolean indexing with multi-dimensional key arrays 294241734
824460304 https://github.com/pydata/xarray/issues/1887#issuecomment-824460304 https://api.github.com/repos/pydata/xarray/issues/1887 MDEyOklzc3VlQ29tbWVudDgyNDQ2MDMwNA== shoyer 1217238 2021-04-22T00:59:25Z 2021-04-22T00:59:25Z MEMBER

OK great. To confirm, this is what it would look like:

Yes, this looks right to me.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Boolean indexing with multi-dimensional key arrays 294241734
824329772 https://github.com/pydata/xarray/issues/1887#issuecomment-824329772 https://api.github.com/repos/pydata/xarray/issues/1887 MDEyOklzc3VlQ29tbWVudDgyNDMyOTc3Mg== shoyer 1217238 2021-04-21T20:16:10Z 2021-04-21T20:16:10Z MEMBER

I've been trying to conceptualize why I think the where equivalence (the original proposal) is better than the stack proposal (the latter).

Here are two reasons why I like the stack version:

  1. It's more NumPy like -- boolean indexing in NumPy returns a flat array in the same way
  2. It doesn't need dtype promotion to handle possibly missing values, so it will have more predictable semantics.

As a side note: one nice feature of using isel() for stacking is that it does not create a MultiIndex, which can be expensive. But there's no reason why we necessarily need to do that for stack(). I'll open a new issue to discuss adding an optional parameter.

  • I'm not sure how the setitem would work; da[key] = value?

To match the semantics of NumPy, value would need to have matching dims/coords to those of da[key]. In other words, it would also need to be stacked.

  • If someone wants the stack result, it's less work to do original -> where result -> stack result relative to original -> stack result -> where result; which suggests they're more composable?

I'm not quite sure this is true -- it's the difference between needing to call stack() vs unstack().

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Boolean indexing with multi-dimensional key arrays 294241734
823673654 https://github.com/pydata/xarray/issues/1887#issuecomment-823673654 https://api.github.com/repos/pydata/xarray/issues/1887 MDEyOklzc3VlQ29tbWVudDgyMzY3MzY1NA== shoyer 1217238 2021-04-20T23:50:34Z 2021-04-20T23:50:34Z MEMBER

It's worth noting that there is at least one other way boolean indexing could work:

  • ds[key] could work like ds.stack({key.name: key.dims}).isel({key.name: np.flatnonzero(key.data)}), except without creating a MultiIndex. Arguably this might be more useful and also more consistent with NumPy itself. It's also more similar to the operation @Hoeze wants in https://github.com/pydata/xarray/issues/5179.

We can't support both with the same syntax, so we have to make a choice here :).

See also the discussion about what drop_duplicates/unique should do over in https://github.com/pydata/xarray/pull/5089.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Boolean indexing with multi-dimensional key arrays 294241734

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