Skip to content

swap_dims should support dimension names that are not existing variables #1855

Closed
@shoyer

Description

@shoyer

Code Sample, a copy-pastable example if possible

input_ds = xarray.Dataset({'foo': ('x', [1, 2])}, {'x': [0, 1]})
input_ds.swap_dims({'x': 'z'})

Problem description

Currently this results in the error KeyError: 'z'

Expected Output

We now support dimensions without associated coordinate variables. So swap_dims() should be able to create new dimensions (e.g., z in this example) even if there isn't already a coordinate variable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions