We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f346574 commit d2a14f9Copy full SHA for d2a14f9
pandas/tests/indexing/multiindex/test_multiindex.py
@@ -98,3 +98,24 @@ def test_multiindex_with_datatime_level_preserves_freq(self):
98
result = df.loc[0].index
99
tm.assert_index_equal(result, dti)
100
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