#NEWLINE# def test_reset_index_multiindex_col( self ) : #NEWLINE# #INDENT# vals = np . random . randn ( 3 , 3 ) . astype ( object ) #NEWLINE# idx = [ 'x' , 'y' , 'z' ] #NEWLINE# full = np . hstack ( ( [ [ x ] for x in idx ] , vals ) ) #NEWLINE# df = DataFrame ( vals , Index ( idx , name = 'a' ) , columns = [ [ 'b' , 'b' , 'c' ] , [ 'mean' , 'median' , 'mean' ] ] ) #NEWLINE# rs = df . reset_index ( ) #NEWLINE# xp = DataFrame ( full , columns = [ [ 'a' , 'b' , 'b' , 'c' ] , [ '' , 'mean' , 'median' , 'mean' ] ] ) #NEWLINE# assert_frame_equal ( rs , xp ) #NEWLINE# rs = df . reset_index ( col_fill = None ) #NEWLINE# xp = DataFrame ( full , columns = [ [ 'a' , 'b' , 'b' , 'c' ] , [ 'a' , 'mean' , 'median' , 'mean' ] ] ) #NEWLINE# assert_frame_equal ( rs , xp ) #NEWLINE# rs = df . reset_index ( col_level = 1 , col_fill = 'blah' ) #NEWLINE# xp = DataFrame ( full , columns = [ [ 'blah' , 'b' , 'b' , 'c' ] , [ 'a' , 'mean' , 'median' , 'mean' ] ] ) #NEWLINE# assert_frame_equal ( rs , xp ) #NEWLINE# df = DataFrame ( vals , MultiIndex . from_arrays ( [ [ 0 , 1 , 2 ] , [ 'x' , 'y' , 'z' ] ] , names = [ 'd' , 'a' ] ) , columns = [ [ 'b' , 'b' , 'c' ] , [ 'mean' , 'median' , 'mean' ] ] ) #NEWLINE# rs = df . reset_index ( 'a' ) #NEWLINE# xp = DataFrame ( full , Index ( [ 0 , 1 , 2 ] , name = 'd' ) , columns = [ [ 'a' , 'b' , 'b' , 'c' ] , [ '' , 'mean' , 'median' , 'mean' ] ] ) #NEWLINE# assert_frame_equal ( rs , xp ) #NEWLINE# rs = df . reset_index ( 'a' , col_fill = None ) #NEWLINE# xp = DataFrame ( full , Index ( lrange ( 3 ) , name = 'd' ) , columns = [ [ 'a' , 'b' , 'b' , 'c' ] , [ 'a' , 'mean' , 'median' , 'mean' ] ] ) #NEWLINE# assert_frame_equal ( rs , x ) #NEWLINE# rs = df . reset_index ( 'a' , col_fill = 'blah' , col_level = 1 ) #NEWLINE# xp = DataFrame ( full , Index ( lrange ( 3 ) , name = 'd' ) , columns = [ [ 'blah' , 'b' , 'b' , 'c' ] , [ 'a' , 'mean' , 'median' , 'mean' ] ] ) #NEWLINE# assert_frame_equal ( rs , xp )