In [1]: data = [ ...: {'id': '10', 'animal' : 'cat'}, ...: {'id': '11', 'animal' : 'dog'}, ...: {'id': '3', 'animal' : 'pigeon'}, ...: {'id': '10', 'color' : 'yellow'}, ...: {'id': '11', 'color' : 'brown'}, ...: {'id': '3', 'color' : 'grey'}, ...: {'id': '10', 'type' : 'furry'}, ...: {'id': '11', 'type' : 'fluffy'}, ...: {'id': '3', 'type' : 'dirty'}, ...: ] In [2]: from collections import defaultdict ...: ids = defaultdict(dict) ...: for d in data: ...: ids[d["id"]].update(d) ...: In [6]: list(ids.values()) Out[6]: [{'id': '10', 'animal': 'cat', 'color': 'yellow', 'type': 'furry'}, {'id': '11', 'animal': 'dog', 'color': 'brown', 'type': 'fluffy'}, {'id': '3', 'animal': 'pigeon', 'color': 'grey', 'type': 'dirty'}]
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter