【发布时间】:2017-10-14 21:52:47
【问题描述】:
我的程序中有一个创建运行时的字典,需要转换为 pandas 数据框。
dictio={'a':'abc','b':'zyx','c':'prq'}
df=pd.Dataframe(dictio)
上面的代码返回一个空的数据框,其中创建了列。谁能指出我错过了什么?
【问题讨论】:
标签: python python-3.x pandas dictionary
我的程序中有一个创建运行时的字典,需要转换为 pandas 数据框。
dictio={'a':'abc','b':'zyx','c':'prq'}
df=pd.Dataframe(dictio)
上面的代码返回一个空的数据框,其中创建了列。谁能指出我错过了什么?
【问题讨论】:
标签: python python-3.x pandas dictionary
#use from_dict and set orient to index and then transpose in the end.
pd.DataFrame.from_dict(dictio,orient='index').T
Out[263]:
a c b
0 abc prq zyx
【讨论】: