I have a list of dictionaries and each dictionary contains exactly the same keys. I want to find the average value for each key and I would like to know how to do it using r
Here is a terrible one liner using list comprehension. You probably are better off not using this.
final = dict(zip(lst[0].keys(), [n/len(lst) for n in [sum(i) for i in zip(*[tuple(x1.values()) for x1 in lst])]]))
for key, value in final.items():
print (key, value)
#Output
recall 0.818703703704
precision 0.820167289406
f_measure 0.818495375556
accuracy 0.79