#NEWLINE# @ pytest . mark . parametrize ( 'how' , [ 'inner' , 'outer' , 'left' , 'right' ] ) #NEWLINE# def test_merge_by_index_patterns( how ) : #NEWLINE# #INDENT# pdf1l = pd . DataFrame ( { #NEWLINE# #INDENT# 'a' : [ 1 , 2 , 3 , 4 , 5 , 6 , 7 ] , #NEWLINE# 'b' : [ 7 , 6 , 5 , 4 , 3 , 2 , 1 ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# pdf1r = pd . DataFrame ( { #NEWLINE# #INDENT# 'c' : [ 1 , 2 , 3 , 4 , 5 , 6 , 7 ] , #NEWLINE# 'd' : [ 7 , 6 , 5 , 4 , 3 , 2 , 1 ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# pdf2l = pd . DataFrame ( { #NEWLINE# #INDENT# 'a' : [ 1 , 2 , 3 , 4 , 5 , 6 , 7 ] , #NEWLINE# 'b' : [ 7 , 6 , 5 , 4 , 3 , 2 , 1 ] , #NEWLINE# #UNINDENT# } , index = list ( 'abcdefg' ) ) #NEWLINE# pdf2r = pd . DataFrame ( { #NEWLINE# #INDENT# 'c' : [ 7 , 6 , 5 , 4 , 3 , 2 , 1 ] , #NEWLINE# 'd' : [ 7 , 6 , 5 , 4 , 3 , 2 , 1 ] , #NEWLINE# #UNINDENT# } , index = list ( 'abcdefg' ) ) #NEWLINE# pdf3l = pdf2l #NEWLINE# pdf3r = pd . DataFrame ( { #NEWLINE# #INDENT# 'c' : [ 6 , 7 , 8 , 9 ] , #NEWLINE# 'd' : [ 5 , 4 , 3 , 2 ] , #NEWLINE# #UNINDENT# } , index = list ( 'abdg' ) ) #NEWLINE# pdf4l = pdf2l #NEWLINE# pdf4r = pd . DataFrame ( { #NEWLINE# #INDENT# 'c' : [ 9 , 10 , 11 , 12 ] , #NEWLINE# 'd' : [ 5 , 4 , 3 , 2 ] , #NEWLINE# #UNINDENT# } , index = list ( 'abdg' ) ) #NEWLINE# pdf5l = pd . DataFrame ( { #NEWLINE# #INDENT# 'a' : [ 1 , 1 , 2 , 2 , 3 , 3 , 4 ] , #NEWLINE# 'b' : [ 7 , 6 , 5 , 4 , 3 , 2 , 1 ] , #NEWLINE# #UNINDENT# } , index = list ( 'lmnopqr' ) ) #NEWLINE# pdf5r = pd . DataFrame ( { #NEWLINE# #INDENT# 'c' : [ 1 , 1 , 1 , 1 ] , #NEWLINE# 'd' : [ 5 , 4 , 3 , 2 ] , #NEWLINE# #UNINDENT# } , index = list ( 'abcd' ) ) #NEWLINE# pdf6l = pd . DataFrame ( { #NEWLINE# #INDENT# 'a' : [ 1 , 1 , 2 , 2 , 3 , 3 , 4 ] , #NEWLINE# 'b' : [ 7 , 6 , 5 , 4 , 3 , 2 , 1 ] , #NEWLINE# #UNINDENT# } , index = list ( 'cdefghi' ) ) #NEWLINE# pdf6r = pd . DataFrame ( { #NEWLINE# #INDENT# 'c' : [ 1 , 2 , 1 , 2 ] , #NEWLINE# 'd' : [ 5 , 4 , 3 , 2 ] , #NEWLINE# #UNINDENT# } , index = list ( 'abcd' ) ) #NEWLINE# pdf7l = pd . DataFrame ( { #NEWLINE# #INDENT# 'a' : [ 1 , 1 , 2 , 2 , 3 , 3 , 4 ] , #NEWLINE# 'b' : [ 7 , 6 , 5 , 4 , 3 , 2 , 1 ] , #NEWLINE# #UNINDENT# } , index = list ( 'abcdefg' ) ) #NEWLINE# pdf7r = pd . DataFrame ( { #NEWLINE# #INDENT# 'c' : [ 5 , 6 , 7 , 8 ] , #NEWLINE# 'd' : [ 5 , 4 , 3 , 2 ] , #NEWLINE# #UNINDENT# } , index = list ( 'fghi' ) ) #NEWLINE# for ( pdl , pdr ) in [ ( pdf1l , pdf1r ) , ( pdf2l , pdf2r ) , ( pdf3l , pdf3r ) , ( pdf4l , pdf4r ) , ( pdf5l , pdf5r ) , ( pdf6l , pdf6r ) , ( pdf7l , pdf7r ) ] : #NEWLINE# #INDENT# for ( lpart , rpart ) in [ ( 2 , 2 ) , ( 3 , 2 ) , ( 2 , 3 ) ] : #NEWLINE# #INDENT# ddl = dd . from_pandas ( pdl , lpart ) #NEWLINE# ddr = dd . from_pandas ( pdr , rpart ) #NEWLINE# eq ( dd . merge ( ddl , ddr , how = how , left_index = True , right_index = True ) , pd . merge ( pdl , pdr , how = how , left_index = True , right_index = True ) ) #NEWLINE# eq ( dd . merge ( ddr , ddl , how = how , left_index = True , right_index = True ) , pd . merge ( pdr , pdl , how = how , left_index = True , right_index = True ) ) #NEWLINE# eq ( ddr . merge ( ddl , how = how , left_index = True , right_index = True ) , pdr . merge ( pdl , how = how , left_index = True , right_index = True ) ) #NEWLINE# eq ( ddl . merge ( ddr , how = how , left_index = True , right_index = True ) , pdl . merge ( pdr , how = how , left_index = True , right_index = True ) ) #NEWLINE# list_eq ( dd . merge ( ddl , ddr , how = how , left_on = 'a' , right_on = 'c' ) , pd . merge ( pdl , pdr , how = how , left_on = 'a' , right_on = 'c' ) ) #NEWLINE# list_eq ( dd . merge ( ddl , ddr , how = how , left_on = 'b' , right_on = 'd' ) , pd . merge ( pdl , pdr , how = how , left_on = 'b' , right_on = 'd' ) ) #NEWLINE# list_eq ( dd . merge ( ddr , ddl , how = how , left_on = 'c' , right_on = 'a' ) , pd . merge ( pdr , pdl , how = how , left_on = 'c' , right_on = 'a' ) ) #NEWLINE# list_eq ( dd . merge ( ddr , ddl , how = how , left_on = 'd' , right_on = 'b' ) , pd . merge ( pdr , pdl , how = how , left_on = 'd' , right_on = 'b' ) ) #NEWLINE# list_eq ( ddl . merge ( ddr , how = how , left_on = 'a' , right_on = 'c' ) , pdl . merge ( pdr , how = how , left_on = 'a' , right_on = 'c' ) ) #NEWLINE# list_eq ( ddl . merge ( ddr , how = how , left_on = 'b' , right_on = 'd' ) , pdl . merge ( pdr , how = how , left_on = 'b' , right_on = 'd' ) ) #NEWLINE# list_eq ( ddr . merge ( ddl , how = how , left_on = 'c' , right_on = 'a' ) , pdr . merge ( pdl , how = how , left_on = 'c' , right_on = 'a' ) ) #NEWLINE# list_eq ( ddr . merge ( ddl , how = how , left_on = 'd' , right_on = 'b' ) , pdr . merge ( pdl , how = how , left_on = 'd' , right_on = 'b' ) )