average list of dictionaries in python -


i have list of dictionary this

data = [{'name': 'john', 'height': 176, 'weight':62, 'iq':120,..},...] 

the .. signifies various other integer/float attributes , elements of list has same format..

i want average height, weight , other numerical attributes in cleanest/easiest way.

i not come better way normal looping messy... , don't want use external packages

you can use following

sum([item['weight'] item in data])/len(data) 

and use

float(len(data))  

if want more exact value.


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -