I have extracted the data of interest from files into a dictionary which contains a dictionary. Now I want to unpack the nested dictionary to make a bigger dataframe that I can analyze. This is my data:
sample = { 'name' : ['cake', 'plum', 'jam'], 'model' : [ 'model_A', 'model_A', 'model_C'], 'data' : [ { 'one': ['A','B', 'C'], 'two': [ 1, 2, 3] }, { 'one': [ 'D', 'E', 'F'], 'two': [ 4, 5, 6]}, {'one': ['G', 'H', 'I'], 'two': [ 7, 8, 9] }]}
I have tried a variety of unpacking methods, including turning the dictionary into slices of pd.Series, and I just can't find anything efficient or working.
This is the dataframe I want:
'name' 'model' 'one' 'two'
0 'cake' 'modle_A' 'A' 1
1 'cake' 'modle_A' 'B' 2
2 'cake' 'modle_A' 'C' 3
3 'plum' 'modle_A' 'D' 4
4 'plum' 'model_A' 'E' 5
5 'plum' 'model_A' 'F' 6
6 'jam' 'model_C' 'G' 7
7 'jam' 'model_C' 'H' 8
8 'jam' 'model_C' 'J' 9