【发布时间】:2021-09-06 15:00:21
【问题描述】:
我使用 Twitter API 学术轨道收集了推文数据。其中一列是关于引用的推文唯一 ID 的字典列表。
| No | Referenced_tweets |
|---|---|
| 1 | [{'type': 'replied_to', 'id': '1212086431889313792'}] |
| 2 | [{'type': 'quoted', 'id': '1345063319540002817'}, {'type': 'replied_to', 'id': '1345066320761655296'}] |
| 3 | [{'type': 'retweeted', 'id': '1344718164974833667'}, {'type': 'replied_to', 'id': '1211798476062908422'}] |
我想像下面这样转换这些数据。
| No | replied_to | quoated | retweeted |
|---|---|---|---|
| 1 | 1212086431889313792 | ||
| 2 | 1345066320761655296 | 1345063319540002817 | |
| 3 | 1211798476062908422 | 1344718164974833667 |
如果我使用“json_normalize”,它会导致错误消息(TypeError:字符串索引必须是整数)。如何使用 Python?
【问题讨论】:
-
你能提供这个例子的原始json回复吗?
标签: python list api dictionary twitter