I have a dictionary, with 300 key value pairs, where each of the keys are integers and the values are dictionaries with three key value pairs. The inner dictionaries all have the same keys, but different values. The whole thing looks pretty much like this:
nested_dicts =
{1: {'name1':88.4,
'name2':22.1,
'name3':115.7},
2: {'name1':89.4,
'name2':23.7,
'name3':117.9}
...
300:{'name1':110.1,
'name2':36.6,
'name3':122.4}
}
If it's not clear from the above example of the data structure, this nested dictionary should probably look like this:
better_dict =
{'name1': [88.4, 89.4, ..., 110.1],
'name2': [22.1, 23.7, ..., 36.6],
'name3': [115.7, 117.9, ..., 122.4]}
So, I'd like to do a transformation from nested_dicts to better_dict.
I'm having trouble pulling this off. I've gotten close, but my trouble comes from trying to figure out how to make sure that the resulting lists are in the correct order. That is, the order of the values in the list should correspond to the keys in the outer dictionary of the original nested_dict. Also, my code uses for loops, but I feel like this is a natural application of generators/list comprehensions. Any help would be appreciated.