I have a list of dictionaries. Each dictionary has several key-values, and a single arbitrary (but important) key-value pair. For example
thelist = [
{"key" : "value1", "k2" : "va1", "ignore_key" : "arb1"},
{"key" : "value2", "k2" : "va2", "ignore_key" : "arb11"},
{"key" : "value2", "k2" : "va2", "ignore_key" : "arb113"}
]
I would like to remove the duplicate dictionaries such that only the non- "ignore-key" values are ignored. I have seen a related question on so - but it only considers entirely identical dicts. Is there a way to remove the almost duplicate such that the data above becomes
thelist = [
{"key" : "value1", "k2" : "va1", "ignore_key" : "arb1"},
{"key" : "value2", "k2" : "va2", "ignore_key" : "arb11"}
]
It doesn't matter which of the duplicates is ignored. How can I do this?