Answers for "how to find the outliers in a data set in pandas"

2

delete outliers in pandas

cols = ['col_1', 'col_2'] # one or more

Q1 = df[cols].quantile(0.25)
Q3 = df[cols].quantile(0.75)
IQR = Q3 - Q1

df = df[~((df[cols] < (Q1 - 1.5 * IQR)) |(df[cols] > (Q3 + 1.5 * IQR))).any(axis=1)]
Posted by: Guest on December-02-2020

Code answers related to "how to find the outliers in a data set in pandas"

Python Answers by Framework

Browse Popular Code Answers by Language