["python","pandas"]
pandas get column average/mean

I can't get the average or mean of a column in pandas. A have a dataframe. Neither of things I tried below gives me the average of the column weight >>> allDF ID birthyear weight 0 619040 1962 0.1231231 1 600161 1963 0.981742 2 25602033 1963 1.3123124 3 624870 1987 0.94212 The following returns several values, not one: allDF[['weight']].mean(axis=1) So does this: allDF.groupby('weight').mean()
If you only want the mean of the weight column, select the column (which is a Series) and call .mean(): In [479]: df Out[479]: ID birthyear weight 0 619040 1962 0.123123 1 600161 1963 0.981742 2 25602033 1963 1.312312 3 624870 1987 0.942120 In [480]: df.loc[:, 'weight'].mean() Out[480]: 0.83982437500000007