I have a nested dictionary, whereby the sub-dictionary use lists:
nested_dict = {'string1': {69: [1231, 232], 67:[682, 12], 65: [1, 1]}, 
    `string2` :{28672: [82, 23], 22736:[82, 93, 1102, 102], 19423: [64, 23]}, ... }
There are at least two elements in the list for the sub-dictionaries, but there could be more.
I would like to "unfold" this dictionary into a pandas DataFrame, with one column for the first dictionary keys (e.g. 'string1', 'string2', ..), one column for the sub-directory keys, one column for the first item in the list, one column for the next item, and so on.
Here is what the output should look like:
col1       col2    col3     col4    col5    col6
string1    69      1231     232
string1    67      682      12
string1    65      1        1
string2    28672   82       23
string2    22736   82       93      1102    102
string2    19423   64       23
Naturally, I try to use pd.DataFrame.from_dict:
new_df = pd.DataFrame.from_dict({(i,j): nested_dict[i][j] 
                           for i in nested_dict.keys() 
                           for j in nested_dict[i].keys()
                           ... 
Now I'm stuck. And there are many existing problems:
- How do I parse the strings (i.e. the - nested_dict[i].values()) such that each element is a new pandas DataFrame column?
- The above will actually not create a column for each field 
- The above will not fill up the columns with elements, e.g. - string1should be in each row for the sub-directory key-value pair. (For- col5and- col6, I can fill the NA with zeros)
- I'm not sure how to name these columns correctly. 
 
     
     
    