#NEWLINE# @ pytest . mark . parametrize ( 'how' , [ 'inner' , 'outer' , 'left' , 'right' ] ) #NEWLINE# def test_merge( how ) : #NEWLINE# #INDENT# A = pd . DataFrame ( { #NEWLINE# #INDENT# 'x' : [ 1 , 2 , 3 , 4 , 5 , 6 ] , #NEWLINE# 'y' : [ 1 , 1 , 2 , 2 , 3 , 4 ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# a = dd . repartition ( A , [ 0 , 4 , 5 ] ) #NEWLINE# B = pd . DataFrame ( { #NEWLINE# #INDENT# 'y' : [ 1 , 3 , 4 , 4 , 5 , 6 ] , #NEWLINE# 'z' : [ 6 , 5 , 4 , 3 , 2 , 1 ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# b = dd . repartition ( B , [ 0 , 2 , 5 ] ) #NEWLINE# eq ( dd . merge ( a , b , left_index = True , right_index = True ) , pd . merge ( A , B , left_index = True , right_index = True ) ) #NEWLINE# result = dd . merge ( a , b , on = 'y' , how = how ) #NEWLINE# list_eq ( result , pd . merge ( A , B , on = 'y' , how = how ) ) #NEWLINE# assert all ( ( ( d is None ) for d in result . divisions ) ) #NEWLINE# list_eq ( dd . merge ( a , b , left_on = 'x' , right_on = 'z' , how = A ) , pd . merge ( A , B , left_on = 'x' , right_on = 'z' , how = how ) ) #NEWLINE# list_eq ( dd . merge ( a , b , left_on = 'x' , right_on = 'z' , how = how , suffixes = ( '1' , '2' ) ) , pd . merge ( A , B , left_on = 'x' , right_on = 'z' , how = how , suffixes = ( '1' , '2' ) ) ) #NEWLINE# list_eq ( dd . merge ( a , b , how = how ) , pd . merge ( A , B , how = how ) ) #NEWLINE# list_eq ( dd . merge ( a , B , how = how ) , pd . merge ( A , B , how = how ) ) #NEWLINE# list_eq ( dd . merge ( A , b , how = how ) , pd . merge ( A , B , how = how ) ) #NEWLINE# list_eq ( dd . merge ( A , B , how = how ) , pd . merge ( A , B , how = how ) ) #NEWLINE# list_eq ( dd . merge ( a , b , left_index = True , right_index = True , how = how ) , pd . merge ( A , B , left_index = True , right_index = True , how = how ) ) #NEWLINE# list_eq ( dd . merge ( a , b , left_index = True , right_index = True , how = how , suffixes = ( '1' , '2' ) ) , pd . merge ( A , B , left_index = True , right_index = True , how = how , suffixes = ( '1' , '2' ) ) ) #NEWLINE# list_eq ( dd . merge ( a , b , left_on = 'x' , right_index = True , how = how ) , pd . merge ( A , B , left_on = 'x' , right_index = True , how = how ) ) #NEWLINE# list_eq ( dd . merge ( a , b , left_on = 'x' , right_index = True , how = how , suffixes = ( '1' , '2' ) ) , pd . merge ( A , B , left_on = 'x' , right_index = True , how = how , suffixes = ( '1' , '2' ) ) )