I have multiple dictionaries inside a Python List as below
[{"color": "#CC3", "values": {"y": 83, "x": 9}, "key": 105},
{"color": "#CC3", "values": {"y": 123, "x": 10}, "key": 105},
{"color": "#FF9", "values": {"y": 96, "x": 11}, "key": 106},
{"color": "#33F", "values": {"y": 80, "x": 12}, "key": 104},
{"color": "#CC3", "values": {"y": 117, "x": 13}, "key": 105},
{"color": "#CC3", "values": {"y": 115, "x": 14}, "key": 105},
{"color": "#CC3", "values": {"y": 102, "x": 15}, "key": 105},
{"color": "#FF9", "values": {"y": 111, "x": 16}, "key": 106},
{"color": "#FF9", "values": {"y": 33, "x": 17}, "key": 106}]
In the above list containing dictionaries ,there are keys called 'key' whose value is the same , e.g. 105 , 106 etc , In those dictionary ,the value of the "values" varies , e.g. "values": {"y": 83, "x": 9}
and "values": {"y": 117, "x": 13}
for 105.
I want to add and bring the values for the same "key=xxx" dictionaries in one dictionary
For instance ,say for dictionaries having key=105 , I want to aggregate the "values": [{"y": 83, "x": 9},{"y": 117, "x": 13}]
say inside a list like this
The final consolidated output should retain the original structure cited above
[{"color"="...","values"=[{...},{...}],"key"="..."},....]
What is the best way to accomplish this ?