I have a list of dictionary's that are similar but not completely identical and I want to keep one of them
example:
my_list = [
{"name" : "A","id" : 2,"value" : 279},
{"name" : "A","id" : 3,"value" : 463},
{"name" : "B","id" : 8,"value" : 508},
{"name" : "A","id" : 2,"value" : 647},
{"name" : "A","id" : 2,"value" : 969},
{"name" : "C","id" : 5,"value" : 384}]
I want to remove the dictionary's that share "name" and "id" but keep the one with higher "value
example of what I want it to be like
my_list = [
{"name" : "A","id" : 3,"value" : 463},
{"name" : "B","id" : 8,"value" : 508},
{"name" : "A","id" : 2,"value" : 969},
{"name" : "C","id" : 5,"value" : 384}]
the values that got removed are
{"name" : "A","id" : 2,"value" : 279},
{"name" : "A","id" : 2,"value" : 647}
because {"name" : "A","id" : 2,"value" : 969}
have more "value"
{"name" : "A","id" : 3,"value" : 463}
didn't get removed because the "id" is different
how can i do that?
i tried looking at some questions like
How to remove duplicate elements of, list of dictionaries in python