How to change coordinate values to a MultiIndex
?
#7639
Unanswered
AlexAndorra
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm running into an issue and I can't figure out if it's something the dev team wanted, or if it's a bug. In both cases, I don't know how to solve this yet, so thanks a lot for any pointers!
Context
I have an xarray object coming from a Bayesian model (I'm using PyMC and ArviZ). One of the dimensions in the model is called
obs_idx
, with coordinatesnp.arange(1989)
(that's the amount of data I have).What I wanna do
For analysis and plot, I wanna switch
obs_idx
's coordinates to the PandasMultiIndex
that uniquely identifies the observations. So I'm doing:This used to work really well with xarray
2022.9.0
, as you can see in the screenshot below:What I cannot do for now
As of xarray
2023.2.0
, this doesn't work anymore, and I can't understand why for now:As you can see, the
MultiIndex
is passed toobs_idx
, but the new coordinates are not added, so afterwards I cannot select on the xarray object by doing, for example:I logically get:
KeyError: "'nationality' is not a valid dimension or coordinate"
Note that:
doesn't work either -- it's giving me the exact same xarray object as in the screenshot above.
Question
Does someone have an idea of what's going on, and how I can solve this?
Thanks a lot in advance, and of course thank you for all your OSS work!
PS: this behavior appeared with
2022.12.0
Beta Was this translation helpful? Give feedback.
All reactions