I need to parse this response into a pandas dataframe.
"predictions": [
{
"predicted_label": 4.0,
"distances": [3.11792408, 3.89746071, 6.32548437],
"labels": [0.0, 1.0, 0.0]
},
{
"predicted_label": 2.0,
"distances": [1.08470316, 3.04917915, 5.25393973],
"labels": [2.0, 2.0, 0.0]
}
]
The end result i am looking for is:
predicted_label | distances | labels | |
---|---|---|---|
0 | 4.0 | 3.11792408 | 0.0. |
1 | 4.0 | 3.89746071 | 1.0 |
2. | 4.0. | 6.32548437 | 0.0 |
same for the second predicted_label 2.0.
I tried using:
pd.json_normalize(result['predictions'], record_path='distances', meta='predicted_label', record_prefix='dist_')
but that will not give me the labels column