Skip to content
This repository was archived by the owner on Jul 10, 2024. It is now read-only.

Commit 6ef6882

Browse files
Add test for pandas-devGH-43321
1 parent 38a16c4 commit 6ef6882

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

pandas/tests/frame/test_arithmetic.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,6 +1061,30 @@ def test_frame_single_columns_object_sum_axis_1():
10611061
tm.assert_series_equal(result, expected)
10621062

10631063

1064+
def test_frame_multi_index_operations():
1065+
# GH 43321
1066+
df = DataFrame(
1067+
{2010: [1, 2, 3], 2020: [3, 4, 5]},
1068+
index=MultiIndex.from_product(
1069+
[["a"], ["b"], [0, 1, 2]], names=["scen", "mod", "id"]
1070+
),
1071+
)
1072+
1073+
s = Series(
1074+
[0.4],
1075+
index=MultiIndex.from_product([["b"], ["a"]], names=["mod", "scen"]),
1076+
)
1077+
1078+
expected = DataFrame(
1079+
{2010: [1.4, 2.4, 3.4], 2020: [3.4, 4.4, 5.4]},
1080+
index=MultiIndex.from_product(
1081+
[["a"], ["b"], [0, 1, 2]], names=["scen", "mod", "id"]
1082+
),
1083+
)
1084+
1085+
tm.assert_frame_equal(df.add(s, axis=0), expected)
1086+
1087+
10641088
# -------------------------------------------------------------------
10651089
# Unsorted
10661090
# These arithmetic tests were previously in other files, eventually

0 commit comments

Comments
 (0)