Vin*_*llo 4 python dictionary list dataframe pandas
非常感谢您的帮助,
我有一个字典列表,需要将其放入数据框中。我知道 pandas 的正常方法是
final_df=pd.DataFrame.from_records(Mixed_and_Poured[0], index='year')
Run Code Online (Sandbox Code Playgroud)
其中 Mixed_and_poured 是一个列表,其中包含另一个实际保存字典的列表
print Mixed_and_Poured
[[{'Country': 'Brazil', u'Internet users': '2.9', 'Year': '2000'}, {'Country': 'Brazil', u'Internet users': '21', 'Year': '2005'}, {'Country': 'Brazil', u'Internet users': '40.7', 'Year': '2010'}, {'Country': 'Brazil', u'Internet users': '45', 'Year': '2011'},
Run Code Online (Sandbox Code Playgroud)
我可以发誓
final_df=pd.DataFrame.from_records(Mixed_and_Poured[0], index='year')
Run Code Online (Sandbox Code Playgroud)
刚刚工作!!但是当我今天运行它时它会抛出
AttributeError: 'list' object has no attribute 'keys'
Run Code Online (Sandbox Code Playgroud)
为什么现在要在此列表中查找键?
| 归档时间: |
|
| 查看次数: |
20218 次 |
| 最近记录: |