我有一本字典
d=dict()
d['a']=2
d['b']=3
d['c']=list([1,5,7])
如果我尝试使用它进行转换
pd.DataFrame.from_dict(d)
然后我明白了
df=
'a' 'b' 'c'
2 3 1
2 3 5
2 3 7
当我想要的时候:
df=
'a' 'b' 'c'
2 3 [1,5,7]
如何获得这种行为?
最佳答案
试试这个:
df = pd.DataFrame.from_dict(d, orient='index').T
关于python - 如何将包含可迭代项作为项目的字典转换为数据框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48446408/