How to sum values from dict where values are string. I mean how to sum values where multiply key is same in dictionary.
values = [
{
This is a simple and specific solution, I am sure there are more general and cleverer ones. :)
from collections import defaultdict
pr = defaultdict(float)
ra = defaultdict(float)
for el in values:
combi = (el['prod_name'], el['prod_hola'])
pr[combi] += el['prihod']
ra[combi] += el['rashod']
results = [dict(rashod=r, prihod=p, \
prod_name=nh[0], prod_hola=nh[1]) \
for r,p,nh in zip(ra.values(), pr.values(), pr)]
print results
gives
[{'rashod': 0.0, 'prihod': 100.0, 'prod_name': 'c', 'prod_hola': 'f'},
{'rashod': 0.0, 'prihod': 1500.0, 'prod_name': 'a', 'prod_hola': 'b'},
{'rashod': 0.0, 'prihod': 460.0, 'prod_name': 'r', 'prod_hola': 't'}]