home / github

Menu
  • Search all tables
  • GraphQL API

issue_comments

Table actions
  • GraphQL API for issue_comments

2 rows where issue = 438947247 and user = 3621629 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

  • 0x0L · 2 ✖

issue 1

  • Stack() & unstack() issues on Multindex · 2 ✖

author_association 1

  • CONTRIBUTOR 2
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions performed_via_github_app issue
709313477 https://github.com/pydata/xarray/issues/2933#issuecomment-709313477 https://api.github.com/repos/pydata/xarray/issues/2933 MDEyOklzc3VlQ29tbWVudDcwOTMxMzQ3Nw== 0x0L 3621629 2020-10-15T13:09:18Z 2020-10-15T13:09:18Z CONTRIBUTOR

You could do it by creating a flatten view of the underlying numpy array, building the multiindex manually and creating a new DataArray from the view and the multiindex.

{
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Stack() & unstack() issues on Multindex 438947247
499248139 https://github.com/pydata/xarray/issues/2933#issuecomment-499248139 https://api.github.com/repos/pydata/xarray/issues/2933 MDEyOklzc3VlQ29tbWVudDQ5OTI0ODEzOQ== 0x0L 3621629 2019-06-05T20:44:29Z 2019-06-05T20:44:29Z CONTRIBUTOR

Hello @ray306

stack/unstack in xarray is a bit different from pandas mechanics.

  • From the stack docstring ``` Stack any number of existing dimensions into a single new dimension.

New dimensions will be added at the end, and the corresponding coordinate variables will be combined into a MultiIndex. `` Breaking it down,da.stack({'index': ['variable']})fails because it's trying to: 1. create a new multi-index with a single level inside (variable) [so far so good but probably not what you had in mind] 2. add a new dimension named 'index' with coordinates given by the newly created index. This part yields the error you saw sincedaalready has an index namedindex`.

To mesh the variable dimension into the index dimension, you first need to unstack it: python da.unstack('index').stack(index=('first', 'second', 'variable'))

  • From the unstack docstring ``` Unstack existing dimensions corresponding to MultiIndexes into multiple new dimensions.

Parameters

dim : str or sequence of str, optional Dimension(s) over which to unstack. By default unstacks all MultiIndexes. `` Yourdaarray only has two dimensions:variableandindex. That's why you can'tda.unstack('first').first` is a coordinate (along the dimension 'index') not a dimension.

You could use da.unstack('index').stack(index=['second']) but this is somehow the same thing as da.unstack() since a multi-index with a single level is totally equivalent to the level itself.

I hope this helps you enjoy xarray and use it more.

{
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Stack() & unstack() issues on Multindex 438947247

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