I have a list in Python:
[{u'key': u'Central District', u'doc_count': 21468},
{u'key': u'Central District', u'doc_count': 6190},
{u'key': u'Central District', u'doc_count': 2060},
{u'key': u'Mexico', u'doc_count': 1884}]
but I need to turn it into this:
[{u'key': u'Central District', u'doc_count': 29718},
{u'key': u'Mexico', u'doc_count': 1884}]
How can I eliminate one of the repeated elements (in this case "Central District"), and get the sum of the doc_count
values of each "Central District"?