Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename_dims to an existing dimension name #4093

Closed
dcherian opened this issue May 25, 2020 · 2 comments
Closed

rename_dims to an existing dimension name #4093

dcherian opened this issue May 25, 2020 · 2 comments

Comments

@dcherian
Copy link
Contributor

ds = xr.Dataset({"a": ("x", np.arange(10)), "b": ("y", np.arange(10))})
ds.rename_dims({"x": "y"})
ValueError: Cannot rename x to y because y already exists. Try using swap_dims instead.

This should be possible since both x and y have the same lengths.
Thoughts?

For indexed dimensions, should we check that the indexes are equal?

@keewis
Copy link
Collaborator

keewis commented May 25, 2020

When I added the error, my reasoning was that renaming dimensions (choosing a different name for a dimension) should not be mixed with swapping dimensions (using a different dimension for a variable).

see also #3645 and #3438

@dcherian
Copy link
Contributor Author

Ah i didn't think swap_dims would work but it does! Thanks.,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants