I have two dictionaries:
a = {a:1, b:2, c:3, d:4}
b = {a:10, b:20, c:30, e:50}
I want to merge to merge these two dictionaries in way of aggregating the common key by summation of values and get something like:
merged = {a:11, b:22, c:33, d:4, e:50}
One possible way might be conversing both dict
s to pandas dataframe
the use group-by()
and then convert back the result into a dict
. However, I am wondering if there is any more efficient way to do that?