I have a df which looks like the following:
| Group. | Score. |
|---|---|
| red | 34 |
| blue | 42 |
| green | 1000 |
| green | 34 |
| blue | 34 |
| red | 42 |
I would like to add a column onto this which specifies if the value is an outlier. If there were no groups then I would use something like:
df['outliers'] = df[df[col] > df[col].mean() + 3 * df[col].std()]
But how would I do this so it is within the groups?