Open lpilz opened 1 year ago
Thanks for the report. There was a recent release (2022.09) with many Index related bugfixes (including MuliIndex) - could you test this?
Thanks for the quick response. This is actually also an issue on 2022.9.0
, I just had the wrong kernel selected. -> Updated the show_version
output
Looks like passing a pandas.MultiIndex
object as dim
argument to concat
was forgotten during the explicit indexes refactor. While this can be fixed (could be tricky), we should deprecate it: it is convenient but probably too neat now that multi-indexes levels have their own, "real" coordinates (see https://github.com/pydata/xarray/issues/6293#issuecomment-1259228475). It should be preferred to explicitly chain concat
with assign_coords
(and set_index
) like the last line in your example.
What happened?
When trying to concatenate data using a Pandas MultiIndex and then unstack it to get two independent dimensions (e.g. for varying different parameters in a simulation), the
unstack
errors. I have seen different errors with different data (MVE errors withValueError: IndexVariable objects must be 1-dimensional
, but my data errors withValueError: cannot re-index or align objects with conflicting indexes found for the following dimensions: 'concat_dim' (2 conflicting indexes)
).One hint at the bug might be that
conc._indexes
shows more indexes thendisplay(conc)
.What did you expect to happen?
Originally (I think it was v2022.3.0) , it used to unstack neatly into the two levels of the multiindex as separate dimensions.
Minimal Complete Verifiable Example
MVCE confirmation
Relevant log output
No response
Anything else we need to know?
No response
Environment