home / github

Menu
  • GraphQL API
  • Search all tables

issue_comments

Table actions
  • GraphQL API for issue_comments

1 row where issue = 137920337 and user = 1217238 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

  • shoyer · 1 ✖

issue 1

  • Index/dimension order not preserved when going from and to DataFrame · 1 ✖

author_association 1

  • MEMBER 1
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions performed_via_github_app issue
191545231 https://github.com/pydata/xarray/issues/780#issuecomment-191545231 https://api.github.com/repos/pydata/xarray/issues/780 MDEyOklzc3VlQ29tbWVudDE5MTU0NTIzMQ== shoyer 1217238 2016-03-03T02:17:36Z 2016-03-03T02:17:36Z MEMBER

So I'm actually not sure whether to call this a bug or a feature. But I can explain why it works this way and maybe we can come up with something better.

With DataArray.to_series(), we are indeed careful to output the hierarchical index in the same order as the array dimensions. So it works there.

But on a Dataset, we don't necessarily have a unique ordering for the dimensions, because in general (though somewhat rarely in practice) the ordering of dimensions can differ between variables. This is why Dataset.dims returns a SortedKeysDict -- to avoid any implicit state derived off the order in which dimensions were added.

When converting a DataFrame, we currently build the MultiIndex independently of the data variables, so somewhat logically we simply take dimensions in sorted order. It might make more sense, though, to instead order levels in order of appearance on Dataset (non-index?) variables. I do try to avoid making heuristic choices like this, though, which is why it didn't make it into xarray already.

This code is pretty self-contained if you want to experiment and/or put together a PR: https://github.com/pydata/xarray/blob/v0.7.1/xarray/core/dataset.py#L1858-L1872

Basically, you need to ensure that ordered_dims is an OrderedDict with keys in the order you want for the resulting DataFrame.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Index/dimension order not preserved when going from and to DataFrame 137920337

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