I want to join the dictionaries in a list whose key ‘user’ are the same, but I don’t realize how. for example:
[{'count2': 34, 'user': 2},
{'count4': 233, 'user': 2},
{'count2': 234, 'user': 4},
{'count4': 344, 'user': 5}]
would become:
[{'count2': 34, 'count4': 233, 'user': 2 },
{'count2': 234, 'user': 4},
{'count4': 344, 'user': 5}]
I searched extensively without found something similar in stack overflow, any help would be greatly appreciated.
Something like this should work. But there are probably more efficient ways to do it (and in fewer lines)…