I have a dictionary that looks like this.,
CombinedDict = {'Abamectin': [63, 31, 53], 'Difenzoquat metilsulfate': [185, 49, 152], 'Chlorpyrifos': [14, 26, 56], 'Dibutyl phthalate': [25, -17, -18]
etc. In total, I have 48 different keys.
What I'm trying to get is the average of three numbers. So I would get a voice recorder that looks like this.,
AvgDictName = {'Abamectin': [49], 'Difenzoquat metilsulfate': [128], 'Chlorpyrifos': [32], 'Dibutyl phthalate': [-3] . . .
I tried to use this line
AvgDictName = dict([(key, float(sum([int(i) for i in values])) / len(values)) for key, values in CombinedDict])
But I get too many values ββto unpack the error Any ideas? I think this could also be done by entering a dict into the list and finding the middle of the list using the len and sum commands, and then returning to the dict, but I really don't know how to do this. Thank you, I have the feeling that it is easy.
source share