-1

I have a nested dictionary with the following structure. I am trying to convert it to pandas dataframe, however I have problems to split the 'mappings' dictionary to have it in separate columns.

{'16': 
    {'label': 't1', 
    'prefLab': 'name', 
    'altLabel': ['test1', 'test3'], 
    'map': [{'id': '16', 'idMap': {'ciID': 16, 'map3': '033441'}}]
    }, 
 '17': 
  {'label': 't2', 
  'prefLab': 'name2', 
  'broader': ['18'], 
  'altLabel': ['test2'], 
  'map': [{'id': '17', 'idMap': {'ciID': 17, 'map1': 1006558, 'map2': 1144}}]
  }
 }

ideal outcome would be a dataframe with the following structure.

   label prefLab broader altLab ciID, map1, map2, map3 ... 
16
17 

1 Answers1

-1

Try with this: assuming your json format name is "data" then

train = pd.DataFrame.from_dict(data, orient='index')
  • I tried that already however as I said then the 'map' is still as dict inside the dataframe but I would need it in separate columns. – user1182888 Jun 12 '19 at 06:21