Reputation: 716
I'm getting the error: "pandas.core.base.DataError: No numeric types to aggregate" when I try to get the mean of a column values based on the values of another column.
This is how the columns look:
PRESSEDKEY PALABRA COLOR KEYCORR RT CORRECT
90 v ABUSO red r 496 N
108 v FRACASO blue a 168 N
138 v MORGUE green v 106 Y
150 v ENOJO red r 0 N
156 v ODIO green v 25 Y
I'm trying to get the mean RT of the values "N" and "Y" in the CORRECT column.
This is what I'm trying and gives me the mentioned error:
mean_emo = df_emowords.groupby('CORRECT')['RT'].mean()
How can I solve this?
Upvotes: 0
Views: 187
Reputation: 18367
DataError: No numeric types to aggregate
Can be replicated when the column / data passed to the groupby object is not of numeric type. You have to previously convert it to numeric:
df_emowords['RT'] = pd.to_numeric(df_emowords['RT'],errors='coerce)
And now it can be correctly ran:
mean_emo = df_emowords.groupby('CORRECT')['RT'].mean()
Upvotes: 1