Skip to content

[FEATURE]: dimension attribute are lost when stacking an xarray #6183

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

Closed
lanougue opened this issue Jan 21, 2022 · 2 comments · Fixed by #5692
Closed

[FEATURE]: dimension attribute are lost when stacking an xarray #6183

lanougue opened this issue Jan 21, 2022 · 2 comments · Fixed by #5692

Comments

@lanougue
Copy link

Is your feature request related to a problem?

No

Describe the solution you'd like

Hi all, when stacking an array my_xarray.stack(multi=('x','y')), the attributes of stacked dimension (x and y in the example) are lost. It would be nice to keep them. It would also be nice to have them back when unstacking.
Thanks

Describe alternatives you've considered

No response

Additional context

No response

@keewis
Copy link
Collaborator

keewis commented Jan 21, 2022

this is a side effect of how stack works at the moment: the coordinates which are being stacked are converted to MultiIndex levels, which are not actually variables and thus lose the attributes. The ongoing index refactor promotes MultiIndex levels to coordinates, which means the coordinates don't have to be dropped in the first place.

Have a look at #5692 if you're interested in the current progress.

@lanougue
Copy link
Author

ok, thanks ! I will thus be patient

@benbovy benbovy mentioned this issue Feb 15, 2022
54 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants