For example in the below list, I'd like to combine all dictionaries that share the same 'id' and 'name.'
Input:
l = [{'id':'1','name':'a','key1':'1'},
{'id':'1','name':'a','key2':'3'},
{'id':'1','name':'a','key3':'4'},
{'id':'2','name':'a','key5':'1'},
{'id':'2','name':'a','key7':'c'},
{'id':'1','name':'b','key5':'1'}]
Desired Result:
l = [{'id':'1','name':'a','key1':'1','key2':'3','key3':'4'},
{'id':'2','name':'a','key5':'1','key7':'c'},
{'id':'1','name':'b','key5':'1'}]
If possible, I'd like the function to also take different number of arguments for which keys the dictionaries would have to share for them to combine. For example, if I just wanted to combine based on just the 'id' instead of the 'key' and the 'name,' the result would be different.