json_data = [
{
"meta_info": {"id": 1, "name": "Alice"},
"data": [{"value": 100}, {"value": 200}]
},
{
"meta_info": {"id": 2, "name": "Bob"},
"data": []
},
{
"meta_info": {"id": 3, "name": "Charlie"}
# "data" key is missing
}
]
if i try the
df = pd.json_normalize(json_data, record_path='data', meta=['meta_info.id', 'meta_info.name'], errors='ignore')
Code i am getting the error
KeyError: "Key 'data' not found. If specifying a record_path, all elements of data should have the path.
if above is my Json_Data which is input to the json_normalize function, then below shoukd be my output dataframe, to get below desired out put for to use the pandas.json_normalize funtion.
value | meta_info.id | meta_info.name |
---|---|---|
100.0 | 1 | Alice |
200.0 | 1 | Alice |
NaN | 2 | bob |
Nan | 3 | Charlie |