Skip to content

Commit d2a14f9

Browse files
TST: MultiIndex with complex (#43184)
TST: MultiIndex with complex (#43184)
1 parent f346574 commit d2a14f9

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

pandas/tests/indexing/multiindex/test_multiindex.py

+21
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,24 @@ def test_multiindex_with_datatime_level_preserves_freq(self):
9898
result = df.loc[0].index
9999
tm.assert_index_equal(result, dti)
100100
assert result.freq == dti.freq
101+
102+
def test_multiindex_complex(self):
103+
# GH#42145
104+
complex_data = [1 + 2j, 4 - 3j, 10 - 1j]
105+
non_complex_data = [3, 4, 5]
106+
result = DataFrame(
107+
{
108+
"x": complex_data,
109+
"y": non_complex_data,
110+
"z": non_complex_data,
111+
}
112+
)
113+
result.set_index(["x", "y"], inplace=True)
114+
expected = DataFrame(
115+
{"z": non_complex_data},
116+
index=MultiIndex.from_arrays(
117+
[complex_data, non_complex_data],
118+
names=("x", "y"),
119+
),
120+
)
121+
tm.assert_frame_equal(result, expected)

0 commit comments

Comments
 (0)