小编rau*_*002的帖子

将包含另一个词典列表的词典列表转换为dataframe

我试图找到解决方案,但我无法得到1.我在python中有一个api的以下输出.

insights = [ <Insights> {
    "account_id": "1234",
    "actions": [
        {
            "action_type": "add_to_cart",
            "value": "8"
        },
        {
            "action_type": "purchase",
            "value": "2"
        }
    ],
    "cust_id": "xyz123",
    "cust_name": "xyz",
}, <Insights> {
    "account_id": "1234",
    "cust_id": "pqr123",
    "cust_name": "pqr",
},  <Insights> {
    "account_id": "1234",
    "actions": [
        {
            "action_type": "purchase",
            "value": "45"
        }
    ],
    "cust_id": "abc123",
    "cust_name": "abc",
 }
 ]
Run Code Online (Sandbox Code Playgroud)

我希望数据框像这样

- account_id    add_to_cart purchase    cust_id cust_name
- 1234                    8        2    xyz123  xyz
- 1234                                  pqr123  pqr
- 1234                            45    abc123  abc
Run Code Online (Sandbox Code Playgroud)

当我使用以下内容时

> …
Run Code Online (Sandbox Code Playgroud)

python dictionary dataframe pandas

5
推荐指数
1
解决办法
295
查看次数

标签 统计

dataframe ×1

dictionary ×1

pandas ×1

python ×1