3 Outliers Iqr
3 Outliers Iqr
[4]: df.describe()
[4]: height
count 20.000000
mean 8.390000
std 8.782812
min 1.200000
25% 5.350000
50% 5.700000
75% 6.275000
1
max 40.200000
[6]: IQR = Q3 - Q1
IQR
[6]: 0.9249999999999998
Remove outliers
[9]: df_no_outlier = df[(df.height>lower_limit)&(df.height<upper_limit)]
df_no_outlier
2
12 yoseph 6.0
13 binod 6.1
14 gulshan 6.2
15 johnson 6.5
16 donald 7.1
Exercise
You are given height_weight.csv file which contains heights and weights of 1000 people. Dataset
is taken from here, https://www.kaggle.com/mustafaali96/weight-height
You need to do this,
(1) Load this csv in pandas dataframe and first plot histograms for height and weight parameters
(2) Using IQR detect weight outliers and print them
(3) Using IQR, detect height outliers and print them
Solution