delete duplicate dictionaries in list of dictionary and extract the values of dictionary
id=842
mg=[
{"ss": 81, "rr": 842, "cd": 81},
{"ss": 842, "rr": 81, "cd": 81},
{"ss": 81, "rr": 842, "cd": 81},
{"ss": 842, "rr": 81, "cd": 81},
{"ss": 82, "rr": 842, "cd": 82},
{"ss": 82, "rr": 842, "cd": 82},
{"ss": 83, "rr": 842, "cd": 83},
{"ss": 842, "rr": 83, "cd": 83},
]
new_d = []
for x in mg:
if x not in new_d:
new_d.append(x)
mg=new_d
mglist=[]
length=len(mg)
for i in range(length):
if mg[i].rr==id:
if mg[i] not in mglist:
cr+=1
mglist.append(mg[i])
if mg[i].ss==id:
if mg[i] not in mglist:
cs+=1
mglist.append(mg[i])
print(cr)
print(cs)
I want to delete duplicate rows and then count frequency of id (in first and second column) in this list of dictionary how I could solve my problem with iteration and remove duplication how to delete duplicate dictionaries in list of dictionaries and extract the values of dictionary?