How do I convert a python dictionary to a pandas data frame. This is how I currently do it which is not at all elegant.
import pandas as pd
MyDict={\'key1\':
If you want to use loc() to access each row in the DataFrame by key then
MyDF = pd.DataFrame([v for v in MyDict.values()], columns = ['value'],
index = [k for k in MyDict.keys()])
MyDF then contains
value
key2 value2
key1 value1
and
MyDF.loc['key2'].value
returns
value2
pd.DataFrame({'Keys': MyDict.keys(), 'Values': MyDict.values()})
returns
Keys Values
0 key2 value2
1 key1 value1