mean of all the columns of a panda dataframe? mean of all the columns of a panda dataframe? python-3.x python-3.x

mean of all the columns of a panda dataframe?


You could use particular columns if you need only columns with numbers:

In [90]: df[['A','C']].mean()Out[90]: A      2.7C    681.6dtype: float64

or to change type as @jezrael advice in comment:

df['C'] = df['C'].astype(float)

Probably df.mean trying to convert all object to numeric and if it's fall then it's roll back and calculate only for actual numbers