I have the following nested dictionary and I would like to convert it to a dataframe.
The first two columns will be the keys of the first dictionary and the third column will be the nested dictionary.
Any suggestions? Thanks a lot in advance!
I have the following nested dictionary and I would like to convert it to a dataframe.
The first two columns will be the keys of the first dictionary and the third column will be the nested dictionary.
Any suggestions? Thanks a lot in advance!
That's not the greatest input data, but if you're confident that the structure of the dictionary won't change, you could try something like the below:
DataFrame([
[x[0] for x in nested_dict.keys()],
[x[1] for x in nested_dict.keys()],
[x for x in nested_dict.values()],
]).T
This should give you a DataFrame to your specs.
0 1 2
0 timestamp4 324 {326: 3}
1 timestamp3 323 {325: 2}
2 timestamp 321 {321: 0}
3 timestamp2 322 {323: 1}