Skip to content

inconsistent behavior in stack/unstack along one dimension #1431

Closed

Description

@d-chambers

I am using Ubuntu 16, python 3.6, and xarray 0.9.1

A DataArray can be stacked along one dimension, but when unstack is called a ValueError is raised. It seems that either unstack should work, or calling stack should also raise a ValueError.

import xarray as xr

dims = ['a', 'b']
coords = {'a': range(2), 'b':range(2)}
values = [[0, 0], [0, 0]]

dar = xr.DataArray(values, coords, dims)

stacked = dar.stack(z=('a',))  # this works

unstack = stacked.unstack('z')  # this raises ValueError

Activity

  1. fujiisoup commented on May 28, 2017

    @fujiisoup
    Member

    Hi @d-chambers

    I am currently working for more consistent MultiIndex behaviour in #1426 .
    I will take a look also for stack-unstack behavior.

  2. shoyer commented on May 30, 2017

    @shoyer
    Member

    Agreed, this does seem inconsistent. Thanks for the report!

  3. mathause commented on May 22, 2019

    @mathause
    Collaborator

    This works with current master - so it can probably be closed? @d-chambers? (I think there is a error in the example - shouldn't it be unstack = stacked.unstack('z')?)

  4. d-chambers commented on May 22, 2019

    @d-chambers
    Author

    Yes, fixed the example. This seems to be fixed now, closing. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions