#NEWLINE# def test_align_multiindex( self ) : #NEWLINE# #INDENT# midx = pd . MultiIndex . from_product ( [ range ( 2 ) , range ( 3 ) , range ( 2 ) ] , names = ( 'a' , 'b' , 'c' ) ) #NEWLINE# idx = pd . Index ( range ( 2 ) , name = 'b' ) #NEWLINE# df1 = pd . DataFrame ( np . arange ( 12 , dtype = 'int64' ) , index = midx ) #NEWLINE# df2 = pd . DataFrame ( np . arange ( 2 , dtype = 'int64' ) , index = idx ) #NEWLINE# ( res1l , res1r ) = df1 . align ( df2 , join = 'left' ) #NEWLINE# ( res2l , res2r ) = df2 . align ( df1 , join = 'right' ) #NEWLINE# expl = df1 #NEWLINE# assert_frame_equal ( expl , res1l ) #NEWLINE# assert_frame_equal ( expl , res2r ) #NEWLINE# expr = pd . DataFrame ( ( [ 0 , 0 , 1 , 1 , np . nan , np . nan ] * 2 ) , index = midx ) #NEWLINE# assert_frame_equal ( expr , res1r ) #NEWLINE# assert_frame_equal ( expr , res2l ) #NEWLINE# ( res1l , res1r ) = df1 . align ( df2 , join = 'right' ) #NEWLINE# ( res2l , res2r ) = df2 . align ( df1 , join = 'left' ) #NEWLINE# exp_idx = pd . MultiIndex . from_product ( [ range ( 2 ) , range ( 2 ) , range ( 2 ) ] , names = ( 'a' , 'b' , 'c' ) ) #NEWLINE# expl = pd . DataFrame ( [ 0 , 1 , 2 , 3 , 6 , 7 , 8 , 9 ] , index = exp_idx ) #NEWLINE# assert_frame_equal ( expl , res1l ) #NEWLINE# assert_frame_equal ( expl , res2r ) #NEWLINE# expr = pd . DataFrame ( ( [ 0 , 0 , 1 , 1 ] * 2 ) , index = exp_idx ) #NEWLINE# assert_frame_equal ( expr , res1r ) #NEWLINE# assert_frame_equal ( expr , res2l )