Skip to content

Commit 601170d

Browse files
author
Khor Chean Wei
authored
Test case for concat inconsistent multiIndex (#45822)
1 parent ff48c3e commit 601170d

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

pandas/tests/reshape/concat/test_index.py

+17
Original file line numberDiff line numberDiff line change
@@ -306,3 +306,20 @@ def test_concat_with_various_multiindex_dtypes(
306306
result_df = concat((df1, df2), axis=1)
307307

308308
tm.assert_frame_equal(expected_df, result_df)
309+
310+
def test_concat_multiindex_(self):
311+
# GitHub #44786
312+
df = DataFrame({"col": ["a", "b", "c"]}, index=["1", "2", "2"])
313+
df = concat([df], keys=["X"])
314+
315+
iterables = [["X"], ["1", "2", "2"]]
316+
result_index = df.index
317+
expected_index = MultiIndex.from_product(iterables)
318+
319+
tm.assert_index_equal(result_index, expected_index)
320+
321+
result_df = df
322+
expected_df = DataFrame(
323+
{"col": ["a", "b", "c"]}, index=MultiIndex.from_product(iterables)
324+
)
325+
tm.assert_frame_equal(result_df, expected_df)

0 commit comments

Comments
 (0)