#NEWLINE# def test_from_records_set_index_name( self ) : #NEWLINE# #INDENT# def create_dict( order_id ) : #NEWLINE# #INDENT# return { #NEWLINE# #INDENT# 'order_id' : order_id , #NEWLINE# 'quantity' : np . random . randint ( 1 , 10 ) , #NEWLINE# 'price' : np . random . randint ( 1 , 10 ) , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# documents = [ create_dict ( i ) for i in range ( 10 ) ] #NEWLINE# documents . append ( { #NEWLINE# #INDENT# 'order_id' : 10 , #NEWLINE# 'quantity' : 5 , #NEWLINE# #UNINDENT# } ) #NEWLINE# result = DataFrame . from_records ( documents , index = 'order_id' ) #NEWLINE# self . assertEqual ( result . index . name , 'order_id' ) #NEWLINE# result = DataFrame . from_records ( create_dict , index = [ 'order_id' , 'quantity' ] ) #NEWLINE# self . assertEqual ( result . index . names , ( 'order_id' , 'quantity' ) )