@@ -2024,6 +2024,36 @@ def test_merge_suffix(col1, col2, kwargs, expected_cols):
20242024 tm .assert_frame_equal (result , expected )
20252025
20262026
2027+ @pytest .mark .parametrize (
2028+ "how,expected" ,
2029+ [
2030+ (
2031+ "right" ,
2032+ DataFrame (
2033+ {"A" : [100 , 200 , 300 ], "B1" : [60 , 70 , np .nan ], "B2" : [600 , 700 , 800 ]}
2034+ ),
2035+ ),
2036+ (
2037+ "outer" ,
2038+ DataFrame (
2039+ {
2040+ "A" : [100 , 200 , 1 , 300 ],
2041+ "B1" : [60 , 70 , 80 , np .nan ],
2042+ "B2" : [600 , 700 , np .nan , 800 ],
2043+ }
2044+ ),
2045+ ),
2046+ ],
2047+ )
2048+ def test_merge_duplicate_suffix (how , expected ):
2049+ left_df = DataFrame ({"A" : [100 , 200 , 1 ], "B" : [60 , 70 , 80 ]})
2050+ right_df = DataFrame ({"A" : [100 , 200 , 300 ], "B" : [600 , 700 , 800 ]})
2051+ result = merge (left_df , right_df , on = "A" , how = how , suffixes = ("_x" , "_x" ))
2052+ expected .columns = ["A" , "B_x" , "B_x" ]
2053+
2054+ tm .assert_frame_equal (result , expected )
2055+
2056+
20272057@pytest .mark .parametrize (
20282058 "col1, col2, suffixes" ,
20292059 [
0 commit comments