【发布时间】:2022-01-13 19:49:38
【问题描述】:
我最近在 Python 中使用 Oracle 的 AI 语言 API 进行了情绪分析。我让 API 迭代了 1300 条推文,并将 API 的输出存储在一个列表中,其中列表中的每个元素对应一个推文 ID。然后我创建了一个字典,其中键是推文 ID,值是 API 为该推文 ID 输出的结果。我现在有一个庞大的字典,字典嵌套在字典中,不知道如何将其转换为 Pandas 中的数据框。
这是我正在使用的字典的前几个条目。
{1292750633104289792: {
"aspects": []
},
1275918779831238656: {
"aspects": []
},
1293251961031204865: {
"aspects": [
{
"length": 8,
"offset": 51,
"scores": {
"Negative": 0.18023298680782318,
"Neutral": 0.0,
"Positive": 0.8197670578956604
},
"sentiment": "Positive",
"text": "building"
}
]
},
1293312774563606531: {
"aspects": []
},
1293375754751881217: {
"aspects": [
{
"length": 4,
"offset": 5,
"scores": {
"Negative": 0.9987309575080872,
"Neutral": 0.0012690634466707706,
"Positive": 0.0
},
"sentiment": "Negative",
"text": "poll"
}
]
}}
非常感谢。
【问题讨论】:
标签: python pandas dataframe dictionary nested