Pandas: using groupby to get mean for each data category
I have a dataframe that looks like this: >>> df[['data','category']] Out[47]: data category 0 4610 2 15 4610 2 22 5307 7 23 5307 7 25 5307 7 ... ... ... Both data and category are numeric so I'm able to do this: >>> df[['data','category']].mean() Out[48]: data 5894.677985 category 13.805886 dtype: float64 And i'm trying to get the mean for each category. It looks straight forward but when I do this: >>> df[['data','category']].groupby('category').mean() or >>> df.groupby('category')['data'].mean() It returns an error like this: DataError: No numeric types to aggregate There's no error if I