Converting Dataframe from list Using a list in the dictionary
# import pandas as pd import pandas as pd
# list of name, degree, score
n =["apple","grape","orange","mango"]
col =["red","green","orange","yellow"]
val =[44,33,22,11]# dictionary of lists dict={'fruit': n,'color': col,'value': val}
df = pd.DataFrame(dict)print(df)
In [20]: timeit df.T.to_dict().values()1000 loops, best of 3:395 µs per loop
In [21]: timeit df.to_dict('records')10000 loops, best of 3:53 µs per loop