I have a dictionary I'm trying to turn into a dataframe. The dictionary is essentially nested, where the keys need to be the column. For instance:
{
"apple":[
{
"price":19,
"store":"xyz"},
{"price":13,
"store":"abc"
}
}],
"pear":[{
"price":25,
"store":"xyz"
}]
}
I'd like the final dataframe to be in the format of
FRUIT PRICE STORE
apple 19 xyz
apple 13 abc
pear 25 xyz
I'm trying to sort through the list by doing some type of a iteration through the 'fruit' keys like such
for fruit in fruit_dict.keys():
df['FRUIT']=fruit
and then using pd.normalize to get the price/store, but this feels incredibly convoluted to me. Is there an easier or better way to get this dictionary 'flattened' down?