home / github / issues

Menu
  • Search all tables
  • GraphQL API

issues: 568968607

This data as json

id node_id number title user state locked assignee milestone comments created_at updated_at closed_at author_association active_lock_reason draft pull_request body reactions performed_via_github_app state_reason repo type
568968607 MDU6SXNzdWU1Njg5Njg2MDc= 3786 DataArray.unstack() leaving dimensions 'in order' 327925 open 0     9 2020-02-21T13:53:40Z 2020-02-23T04:03:06Z   MEMBER      

It's documented that when you .unstack() a DataArray, "New dimensions will be added at the end."

I'm using .unstack() kind of like np.reshape(), to split one dimension into two. From this perspective, it's surprising that new dimensions go at the end, rather than in place of the old dimension. This also means that either the new array is no longer C-contiguous, or the .unstack() operation has had to copy all the data to rearrange it. It appears I'm not the only one to think this: the code sample in #2419 (about adding a reshape method) does the same workaround that I do: unstack and then carefully reorder the dimensions.

First, I'd like to understand: why the end? It seems like there's an obvious place to put unstacked dimensions (ab, c -> a, b, c), but presumably there's some reason it doesn't work that way.

Then, is there anything one can do with xarray today to 'unstack' a dimension while keeping the order, short of using .transpose() afterwards to recreate the desired order? And if not, is there any potential to add a feature for that?

I guess this might touch on missing data: unstack() can create and handle 'gaps', whereas reshape() can't. If so, is there some more limited operation that could only unstack a perfectly regular multiindex - where it's guaranteed to separate into 2 dimensions without creating gaps?

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/3786/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
    13221727 issue

Links from other tables

  • 0 rows from issues_id in issues_labels
  • 9 rows from issue in issue_comments
Powered by Datasette · Queries took 0.556ms · About: xarray-datasette