148148 operator .methodcaller ("melt" , id_vars = ["A" ], value_vars = ["B" ]),
149149 ),
150150 (pd .DataFrame , frame_data , operator .methodcaller ("map" , lambda x : x )),
151- pytest .param (
152- (
153- pd .DataFrame ,
154- frame_data ,
155- operator .methodcaller ("merge" , pd .DataFrame ({"A" : [1 ]})),
156- ),
157- marks = not_implemented_mark ,
158- ),
151+ (pd .DataFrame , frame_data , operator .methodcaller ("merge" , pd .DataFrame ({"A" : [1 ]}))),
159152 (pd .DataFrame , frame_data , operator .methodcaller ("round" , 2 )),
160153 (pd .DataFrame , frame_data , operator .methodcaller ("corr" )),
161154 pytest .param (
@@ -675,3 +668,35 @@ def test_finalize_frame_series_name():
675668 df = pd .DataFrame ({"name" : [1 , 2 ]})
676669 result = pd .Series ([1 , 2 ]).__finalize__ (df )
677670 assert result .name is None
671+
672+ # ----------------------------------------------------------------------------
673+ # Merge tests
674+
675+ @pytest .mark .parametrize (["allow_duplication_on_left" , "allow_duplication_on_right" ],
676+ [
677+ (False , False ),
678+ (False , True ),
679+ (True , False ),
680+ (True , True )
681+ ])
682+ def test_merge_sets_duplication_allowance_flag (allow_duplication_on_left , allow_duplication_on_right ):
683+ """
684+ Check that pandas.merge correctly sets the allow_duplicate_labels flag
685+ on its result.
686+
687+ If one or both of the arguments to merge has its flag set to False,
688+ then the result of merge should have its flag set to False.
689+ Otherwise, the result should have its flag set to True.
690+ """
691+ # Arrange
692+ left = pd .DataFrame ({"test" : [1 ]})
693+ left .set_flags (allows_duplicate_labels = allow_duplication_on_left )
694+ right = pd .DataFrame ({"test" : [1 ]})
695+ right .set_flags (allows_duplicate_labels = allow_duplication_on_right )
696+
697+ # Act
698+ result = left .merge (right , how = "inner" , on = "test" )
699+
700+ # Assert
701+ expected_duplication_allowance = allow_duplication_on_left and allow_duplication_on_right
702+ assert result .flags .allows_duplicate_labels == expected_duplication_allowance
0 commit comments