以不一致的JSON结构解析嵌套数组

时间:2020-09-28 06:04:57

标签: python-3.x dataframe

我正在尝试使用json_normalize在熊猫中解析Json。 问题是json结构不一致。

"AB": [
        {
            "createdAt": "2020-09-24T13:14:04",
            "modifiedAt": "2020-09-24T13:17:56",
            "id": 111,
            "country": "US",
            "gender": "MALE",
            "customAttributes": {
                "whatsAppDisplayName": "A"
            },
            "contactInformation": {
                "phone": [
                    {
                        "number": "971"
                    }
                ]
            }
        }
]

这归一化为一个平面表,但contactInformation.phone列显示为

[
    {
        "number": "971"
    }
]

如何将其标准化? 如果我使用record_path ='contactInformation.phone',尽管在meta列中我指定了contactInformation,phone等列,但我得到了keynot found错误。

任何想法

0 个答案:

没有答案