AttributeError:尝试从字典列表创建 DataFrame 时,“列表”对象没有属性“键”

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)

为什么现在要在此列表中查找键?

Vin*_*llo 5

事实证明,我实际上并不是在操作一个字典列表,最后还隐藏着一个小混蛋列表。

对不起你们!