我有一个带有几个键/值对的python dict,一个值为列表,我正在尝试转换pandas dataframe。转换通用dict对df = pd.DataFrame(dict)
很简单,但是列表正在放弃转换,我正在寻求有关如何处理它的最佳实践的帮助。
例如,以下在示例中,我正在与我合作:
{'foo': 123.0, 'ctr': 0.03, 'bar': 2.3, 'keys': ['2015-05-01', 'us', 'find foo', 'find bar', 'DESKTOP'], 'super': 5.0}
但是,以下是dataFrame的返回 - 该列表在dataframe中创建了多个行。
super ctr foo keys bar
0 5.0 0.03 123.0 2015-05-01 2.3
1 5.0 0.03 123.0 tha 2.3
2 5.0 0.03 123.0 find foo 2.3
3 5.0 0.03 123.0 find bar 2.3
4 5.0 0.03 123.0 DESKTOP 2.3
有没有更好的方法来转换这样的python dict,而不是简单地通过pd.dataframe()将其返回一行,并在dict中使用所有数据返回一行?
非常感谢!
围绕dict
的支架将执行技巧
pd.DataFrame([dict])