Skip to content

Commit 11a5a4b

Browse files
authored
[TST]: Add test for duplicate keys in concat (pandas-dev#36556)
* Add test for 20816 * Modify test * Move test
1 parent ade94e5 commit 11a5a4b

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

pandas/tests/reshape/concat/test_concat.py

+18
Original file line numberDiff line numberDiff line change
@@ -554,3 +554,21 @@ def test_concat_preserves_extension_int64_dtype():
554554
result = pd.concat([df_a, df_b], ignore_index=True)
555555
expected = DataFrame({"a": [-1, None], "b": [None, 1]}, dtype="Int64")
556556
tm.assert_frame_equal(result, expected)
557+
558+
559+
@pytest.mark.parametrize(
560+
("keys", "integrity"),
561+
[
562+
(["red"] * 3, True),
563+
(["red"] * 3, False),
564+
(["red", "blue", "red"], False),
565+
(["red", "blue", "red"], True),
566+
],
567+
)
568+
def test_concat_repeated_keys(keys, integrity):
569+
# GH: 20816
570+
series_list = [Series({"a": 1}), Series({"b": 2}), Series({"c": 3})]
571+
result = concat(series_list, keys=keys, verify_integrity=integrity)
572+
tuples = list(zip(keys, ["a", "b", "c"]))
573+
expected = Series([1, 2, 3], index=MultiIndex.from_tuples(tuples))
574+
tm.assert_series_equal(result, expected)

0 commit comments

Comments
 (0)