1# set the dict to a tuple for hashability, then use {} for set literal and retrn each item to dict.
2[dict(t) for t in {tuple(d.items()) for d in l}]
3# using two maps()
4list(map(lambda t: dict(t), set(list(map(lambda d: tuple(d.items()), l)))))
1import itertools
2mylist = [{'x':2020 , 'y':20},{'x':2020 , 'y':30},{'x':2021 , 'y':10},{'x':2021 , 'y':5}]
3mylist1=[]
4for key, group in itertools.groupby(mylist,lambda x:x["x"]):
5 max_y=0
6 for thing in group:
7 max_y=max(max_y,thing["y"])
8 mylist1.append({"x":key,"y":max_y})
9print(mylist1)
10