I have data of a metric grouped date wise. I have plotted the data, now, how do I remove the values outside the range of the boxplot (outliers)?
All the ['AVG'] data is in a single column, I need it for time series modelling.
Data Science Stack Exchange is a question and answer site for Data science professionals, Machine Learning specialists, and those interested in learning more about the field. It only takes a minute to sign up.Sign up to join this community
Seaborn uses inter-quartile range to detect the outliers. What you need to do is to reproduce the same function in the column you want to drop the outliers. It's quite easy to do in Pandas.
If we assume that your dataframe is called
df and the column you want to filter based
Q1 = df['AVG'].quantile(0.25) Q3 = df['AVG'].quantile(0.75) IQR = Q3 - Q1 filter = (df['AVG'] >= q1 - 1.5 * IQR) & (df['AVG'] <= Q3 + 1.5 *IQR) df.loc[filter]