I have been researching this issue for a while,
for solving 'combining' multiple Counter().object or dicts; But still can`t work it done.
And I found two reference below:
- Is there any pythonic way to combine two dicts (adding values for keys that appear in both)?
- Summing the contents of two collections.Counter() objects
For example I have many 'Counter Type' variable name with order [1 to 100]
:
Name:counter_1 Value:Counter({'a':1, 'b':2, 'c':3})
Name:counter_2 Value:Counter({'b':5, 'c':19, f:17})
Name:counter_3 Value:Counter({'a':11, 'b':22, 'c':33, 'd':97})
...
Name:counter_100 Value:Counter({'c':55, 'd':22, 'e':63, 'f':21})
If I add each of one manually counter_1 + counter_2 + ... + counter_3
, it will make me insane.
Is there more elegant or easier way to sum() it all?
Thanks a million!