From 3c6f3cdf853c9b65c5e60997209c5aa1ec1838be Mon Sep 17 00:00:00 2001 From: Shahar Naveh <50263213+ShaharNaveh@users.noreply.github.com> Date: Fri, 30 Apr 2021 02:34:45 +0300 Subject: [PATCH] TST: Regression test for #33765 (#41169) --- 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 3c8941c6361e0..b9f6e72acf71b 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, ) @@ -1816,3 +1817,22 @@ def test_inplace_arithmetic_series_update(): expected = DataFrame({"A": [2, 3, 4]}) tm.assert_frame_equal(df, expected) + + +def test_arithemetic_multiindex_align(): + """ + 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)