Skip to content

Fix to_index(): return multiindex level as single index - #7105

Merged
dcherian merged 8 commits into
pydata:mainfrom
benbovy:fix-to-index-midx-level
Oct 12, 2022
Merged

dcherian merged 8 commits into
pydata:mainfrom
benbovy:fix-to-index-midx-level

Conversation

@benbovy

@benbovy benbovy commented Sep 29, 2022 •

Copy link
Copy Markdown
Member

@dcherian

dcherian commented Oct 3, 2022

Copy link
Copy Markdown
Contributor

I like this fix in general: we fix the backwards incompatible change and work to remove MultiIndex special cases separately.

Though this PR seems to have broken a lot of things :)

@benbovy

benbovy commented Oct 3, 2022

Copy link
Copy Markdown
Member Author

Yes I agree it would be nice if we can roll back this breaking change. However, it really conflicts with .xindexes that returns the same index instance for each of its corresponding coordinate. This roll back seems to mostly break things where we need to be smart while handling multi-index coordinates passed to DataArray / Dataset constructors. This might be tricky to solve. It would probably be easier to do it after #6392.

@benbovy
benbovy marked this pull request as draft October 3, 2022 21:33
Add Variable._to_index method used internally and returns
multi-index for level variables.
@benbovy

benbovy commented Oct 7, 2022

Copy link
Copy Markdown
Member Author

Tests should be ok now, although this is not a super clean workaround. IndexVariable still needs some more refactoring anyway.

@benbovy
benbovy marked this pull request as ready for review October 7, 2022 12:20
Comment thread xarray/core/utils.py Resolved
@dcherian

Copy link
Copy Markdown
Contributor

Thanks @benbovy

@dcherian
dcherian merged commit f93b467 into pydata:main Oct 12, 2022
@benbovy
benbovy deleted the fix-to-index-midx-level branch December 8, 2022 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

groupby(multi-index level) not working correctly on a multi-indexed DataArray or DataSet

2 participants