BUG: Fix MultiIndex alignment issue in Dataframe-Series binary operat… #61017
+39
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
…ion in case of different levels
.mul
on multi index columns doesnt work. #61009doc/source/whatsnew/v3.0.0.rst
file if fixing a bug or adding a new feature.In case of arithmetic operations between a
DataFrame
with MultiIndex columns and aSeries
, if the two multiindexes don't have the same levels, the output values are allnan
(see example in the original issue).A similar issue for
DataFrame
-DataFrame
arithmetic operations was fixed in #60538. This PR addresses the bug in theDataFrame
-Series
case withaxis=1
(i.e. aligning DataFrame columns with Series MultiIndex).The fix itself is simple - we just use
instead of
because
Series.reindex
needs the new MultiIndex to have identical levels to the current index. Instead, we simply use theridx
object that we already have from a previousIndex.join
call, which does handle partially overlapping levels well.