Python DF to Json Format. with primitive and nested dict

Viewed 6

i have a dataframe i wanted to convert into a specific json format but im quite stuck due to the primitive and nested dict format.

data = {
  "id": ['1', '2'],
  "route_platform": ['data-sets,profile,users,workspaces', ' profile,workspaces'],
  "lastactivity_platform": ['2022-09-19T03:44:40.163Z', '2022-09-08T05:51:07.783Z'],
  "properties": ['properties', 'properties'],
}
df = pd.DataFrame(data)

and i wanted to convert it to this kind of format:

    inputs=[{'id':'1',
             'properties':
                 {
                    'route_platform':'data-sets,profile,users,workspaces','lastactivity_platform':'2022-09-19T03:44:40.163Z',
                 }
             },
            {'id':'2',
             'properties':
                 {
                    'route_platform':'profile,workspaces','lastactivity_platform':'2022-09-08T05:51:07.783Z',
                 }
             },
            ]

0 Answers
Related