#NEWLINE# def test_from_records_to_records( self ) : #NEWLINE# #INDENT# arr = np . zeros ( ( 2 , ) , dtype = 'i4,f4,a10' ) #NEWLINE# arr [ : ] = [ ( 1 , 2.0 , 'Hello' ) , ( 2 , 3.0 , 'World' ) ] #NEWLINE# frame = DataFrame . from_records ( arr ) #NEWLINE# index = np . arange ( len ( arr ) ) [ : : ( - 1 ) ] #NEWLINE# indexed_frame = DataFrame . from_records ( arr , index = index ) #NEWLINE# self . assert_numpy_array_equal ( indexed_frame . index , index ) #NEWLINE# arr2 = np . zeros ( ( 2 , 3 ) ) #NEWLINE# assert_frame_equal ( DataFrame . from_records ( arr2 ) , DataFrame ( arr2 ) ) #NEWLINE# msg = 'Shape of passed values is \\(3, 2\\), indices imply \\(3, 1\\)' #NEWLINE# with assertRaisesRegexp ( ValueError , msg ) : #NEWLINE# #INDENT# DataFrame . from_records ( arr , index = index [ : ( - 1 ) ] ) #NEWLINE# #UNINDENT# indexed_frame = DataFrame . from_records ( arr , index = 'f1' ) #NEWLINE# records = indexed_frame . to_records ( ) #NEWLINE# self . assertEqual ( len ( records . dtype . names ) , 3 ) #NEWLINE# records = indexed_frame . to_records ( index = False ) #NEWLINE# self . assertEqual ( len ( records . dtype . names ) , 2 ) #NEWLINE# self . assertNotIn ( 'index' , records . dtype . names )