From 0d2bed24df61b4be29a3d1becbf024f808c1b402 Mon Sep 17 00:00:00 2001 From: ShaharNaveh <> Date: Mon, 26 Apr 2021 23:21:23 +0300 Subject: [PATCH 1/2] TST: Regression test for #33765 --- pandas/tests/frame/test_arithmetic.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pandas/tests/frame/test_arithmetic.py b/pandas/tests/frame/test_arithmetic.py index c6816fa6481f4..1dbd842bee6b6 100644 --- a/pandas/tests/frame/test_arithmetic.py +++ b/pandas/tests/frame/test_arithmetic.py @@ -12,6 +12,7 @@ import pandas as pd from pandas import ( DataFrame, + Index, MultiIndex, Series, ) @@ -1782,3 +1783,22 @@ def test_inplace_arithmetic_series_update(): expected = DataFrame({"A": [2, 3, 4]}) tm.assert_frame_equal(df, expected) + + +def test_arithemetic_multiindex_align(): # Needs a better name + """ + Regression test for: https://github.com/pandas-dev/pandas/issues/33765 + """ + df1 = DataFrame( + [[1]], + index=["a"], + columns=MultiIndex.from_product([[0], [1]], names=["a", "b"]), + ) + df2 = DataFrame([[1]], index=["a"], columns=Index([0], name="a")) + expected = DataFrame( + [[0]], + index=["a"], + columns=MultiIndex.from_product([[0], [1]], names=["a", "b"]), + ) + result = df1 - df2 + tm.assert_frame_equal(result, expected) From 4da5fc60646bd20776caa6f13176c10cf5822c95 Mon Sep 17 00:00:00 2001 From: ShaharNaveh <> Date: Thu, 29 Apr 2021 16:06:40 +0300 Subject: [PATCH 2/2] Removed comment --- pandas/tests/frame/test_arithmetic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/frame/test_arithmetic.py b/pandas/tests/frame/test_arithmetic.py index e207af142df87..9c95b2f944d18 100644 --- a/pandas/tests/frame/test_arithmetic.py +++ b/pandas/tests/frame/test_arithmetic.py @@ -1795,7 +1795,7 @@ def test_inplace_arithmetic_series_update(): tm.assert_frame_equal(df, expected) -def test_arithemetic_multiindex_align(): # Needs a better name +def test_arithemetic_multiindex_align(): """ Regression test for: https://github.com/pandas-dev/pandas/issues/33765 """