plot = sns.boxplot(y = 'charges', x = 'smoker' , data = df)
I was trying to remove outliers for the "no" category here. For which I filtered the no values
no_charges = d[d.smoker == 'no'].charges
Calculated the IQR
Q1 = no_charges.quantile(0.25)
Q3 = no_charges.quantile(0.75)
IQR = Q3-Q1
Filtered the outliers
da = df.copy()
no = da[da.smoker == 'no']
rem = no[(no.charges > (Q3 + 1.5*IQR)) | (no.charges < (Q3 - 1.5*IQR))]
But I am facing issue when I try to drop the desired data from the main table
da.drop[[(no.charges > (Q3 + 1.5*IQR)) | (no.charges < (Q3 - 1.5*IQR))], inplace=True]
Can we do it this way? If not then how to filter the values?