I am new to Python and need your help. I need to calculate the average for a specific column in a very large array. I would like to use numpy.average function (open to any other suggestions) but can not figure out a way to select a column by its header (e.g. an average for a Flavor_Score column):
Beer_name Tester Flavor_Score Overall_Score
Coors Jim 2.0 3.0
Sam Adams Dave 4.0 4.5
Becks Jim 3.5 3.5
Coors Dave 2.0 2.2
Becks Dave 3.5 3.7
Do I have to transpose the array (it seems there are many functions for rows in pandas and numpy but relatively few for columns (I could be wrong, of course) to get average calculations for a column done?
Second question for the same array: is the best way to use the answer from the first question (calculating the average Flavor_Score) to calculate the average Flavor_Score for a specific beer (among different testers)?
Beer-test="Coors"
for i in Beer_Name():
if i=Beer_test: # recurring average calculation
else: pass
I would hope there is a built-in function for this.
Very much appreciate your help!
df['Flavor_Score'].mean(), for a specific beer:df[df['Beer_Name'] == 'Coors', 'Flavor_Score'].mean()