0

I've been trying to normalize this json with pandas json_normalize

{
    "data": [
        {
            "id": "4d5cb349-5a4d-448b-86fd-07796f470d00",
            "type": "tasks",
            "attributes": {
                "name": "Ingresar requerimiento",
                "state": "resolved",
                "expired": 0,
                "ticket_id": 1212745,
                "created_at": "2022-01-06T20:16:08+00:00",
                "due_date": "2022-03-06T19:15:55+00:00",
                "expiration_date": "2022-03-06T20:15:55+00:00",
                "finished_at": "2022-01-06T20:15:55+00:00",
                "main_task": true,
                "first_node": {
                    "id": 1212745,
                    "code": "in12_1",
                    "name": "Ingresar requerimiento",
                    "uuid": "4d5cb349-5a4d-448b-86fd-07796f470d00"
                },
                "answer": null,
                "comments": "RRHH",
                "description": "Ingrese datos ",
                "pictures": [],
                "code": "in12_1",
                "navigation_levels": [
                    {
                        "id": "e547ef78-369b-4749-8bbb-a6ee79611b9f",
                        "name": "Recursos Humanos",
                        "code": "RRHH",
                        "level": "l1"
                    },
                    {
                        "id": "55d745ca-51ab-409d-b06c-a0474f20922d",
                        "name": "Requerimientos",
                        "code": "req",
                        "level": "l2"
                    },
                    {
                        "id": "8b55fd92-6934-4b6d-ae93-77d20b4321d6",
                        "name": "Otra consulta RRHH",
                        "code": "in10",
                        "level": "l3"
                    }
                ],
                "pending_tasks": 1,
                "meta_accountable_areas": [
                    {
                        "id": "034e7fa1-8a2c-4f30-b99e-9beba2e4535a",
                        "name": "Gerente Tienda"
                    },
                    {
                        "id": "d2ae9049-5e3c-4250-b412-31222778c0ff",
                        "name": "Jefatura de Remuneraciones"
                    }
                ],
                "meta_due_date": {
                    "date": "2022-01-07T20:15:56+00:00",
                    "expired": false
                },
                "meta_state": "open"
            },
            "links": {
                "self": "https://example_url"
            },
            "relationships": {}
        }
    ],
    "links": {
        "prev": null,
        "next": null,
        "first": "https://example_url?filter[period][from]=2022-01-06T00%3A00%3A00-04%3A00&filter[period][to]=2022-01-06T23%3A59%3A59-04%3A00&filter[ticket_id][]=1212745&filter[users][]=03f93744-dfba-4067-aa9e-fa7d7cc02558&filter[ticket_types][]=workflow&per_page=500&page=1&filters[period][from]=2022-01-06T00%3A00%3A00-04%3A00&filters[period][to]=2022-01-06T23%3A59%3A59-04%3A00&filters[ticket_id][]=1212745&filters[users][]=03f93744-dfba-4067-aa9e-fa7d7cc02558&filters[ticket_types][]=workflow",
        "last": "https://example_url?filter[period][from]=2022-01-06T00%3A00%3A00-04%3A00&filter[period][to]=2022-01-06T23%3A59%3A59-04%3A00&filter[ticket_id][]=1212745&filter[users][]=03f93744-dfba-4067-aa9e-fa7d7cc02558&filter[ticket_types][]=workflow&per_page=500&page=1&filters[period][from]=2022-01-06T00%3A00%3A00-04%3A00&filters[period][to]=2022-01-06T23%3A59%3A59-04%3A00&filters[ticket_id][]=1212745&filters[users][]=03f93744-dfba-4067-aa9e-fa7d7cc02558&filters[ticket_types][]=workflow",
        "self": "https://example_url?filter[period][from]=2022-01-06T00%3A00%3A00-04%3A00&filter[period][to]=2022-01-06T23%3A59%3A59-04%3A00&filter[ticket_id][]=1212745&filter[users][]=03f93744-dfba-4067-aa9e-fa7d7cc02558&filter[ticket_types][]=workflow&per_page=500&page=1&filters[period][from]=2022-01-06T00%3A00%3A00-04%3A00&filters[period][to]=2022-01-06T23%3A59%3A59-04%3A00&filters[ticket_id][]=1212745&filters[users][]=03f93744-dfba-4067-aa9e-fa7d7cc02558&filters[ticket_types][]=workflow"
    },
    "meta": {
        "pagination": {
            "current_page": 1,
            "total": 1,
            "per_page": 500
        }
    }
}

the result i get is the following: Dataframe

My problem is that I need in columns the data from the "navigations_levels" and "meta_accountable_areas", I tried to use the record_path in the json_normalize and i get the following error

Key_error

How can i add those 3 columns in my dataframe? Thanks in advance

Derek O
  • 16,770
  • 4
  • 24
  • 43
  • try to look in this post https://stackoverflow.com/questions/38231591/split-explode-a-column-of-dictionaries-into-separate-columns-with-pandas – Tomer S Jan 07 '22 at 16:22
  • Also take a look at https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.explode.html – ozacha Jan 07 '22 at 20:42

0 Answers0