-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Aligning on multi-index with swapped levels gives unclear error message #9952
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
Comments
I suppose you could do a heuristic which tries to 'compare' two multi-indexes to give better feedback. |
Specific to the error message, I suppose the problem is that this message is also used eg when merging a multi-index with a multi-index when the levels are swapped? So probably difficult to get this 'useful' message for all use cases. And regarding the actual use case, is this something we would want to be possible? Should alignment also try to align the levels of a multi-index first before aligning the index itself? |
I think you could simply raise a more informative message if you 'guess' that the levels are swapped. I wouldn't actually try to align though. |
Pandas already does automatic alignment in many cases, so I would like to be able to say that we should align the levels of a multi-index -- except for the fact that currently index names are just metadata, so we would have to guess about the right ordering. Given this fact, I agree with @jreback -- we should just raise a better error message. |
This appears to "work" now (and give a sensible result IMO). I think it would be okay to add a test for this behavior
|
When trying to do a calculation with two dataframes with both multi-indexed rows, but with swapped levels, you get the error message
"NotImplementedError: merging with more than one level overlap on a multi-index is not implemented"
.This is not very informative in this case.
The text was updated successfully, but these errors were encountered: