I have a list of dictionary like this
data = [{'Name': 'john', 'Height': 176, 'Weight':62, 'IQ':120,..},...]
the .. signifies various other integer/float attributes and all elements of the list has same format..
I want to get the average Height, Weight and all other numerical attributes in the cleanest/easiest way.
I could not come up with a better way than normal for looping which was too messy... and i don't want to use any external packages
解决方案
You can use the following
sum([item['Weight'] for item in data])/len(data)
and use
float(len(data))
if you want a more exact value.