JSON到DataFrame的字典列表

时间:2018-07-31 13:25:43

标签: python json pandas dataframe

我有两个字典@font-face font-family Knockout src url(../font/Knockout-HTF28-JuniorFeatherwt.woff2) format(woff2),url(../font/Knockout-HTF28-JuniorFeatherwt.woff) format(woff) dict1

我正在尝试使用JSON加载它们

dict2

然后尝试将其转换为pdf

y = json.loads(json.dumps([dict1, dict2]))

我遇到错误了

df = pd.DataFrame.from_dict(y, orient='index')

当我为一部字典dict1做它

AttributeError: 'str' object has no attribute 'values'

正在工作。我了解在第二种情况下,x = json.loads(dict1) df_x = pd.DataFrame.from_dict(x, orient = 'index') 将作为字典加载,因此能够转换为数据帧。但是,第一种情况,因为它是一个列表,所以不起作用。

那么,如何将字典列表转换为数据框?

0 个答案:

没有答案