Reputation: 3743
here is my code:
df = pd.read_csv("aps.csv")
df.replace('na', np.NaN, inplace=True)
print (df.mean(axis=0))
I expect the mean of each column, but it returns only the mean of the first column! why?
aa_000 59336.499567
dtype: float64
Upvotes: 1
Views: 55
Reputation: 294258
I'm guessing that other columns are dtype
object
Try:
df.apply(pd.to_numeric, errors='coerce').mean()
Upvotes: 3