I'm trying to extract the outliers using a boxplot.
# libraries & dataset
import seaborn as sns
import matplotlib.pyplot as plt
# set a grey background (use sns.set_theme() if seaborn version 0.11.0 or above)
sns.set(style="darkgrid")
df = sns.load_dataset('iris')
sns.boxplot(y=df["species"], x=df["sepal_length"])
plt.show()
The above plot shows an outlier. I tried to extract the outliers using boxplot_stats. But the fliers show an empty array.
from matplotlib.cbook import boxplot_stats
boxplot_stats(data["sepal_length"])
Output
[{'cihi': 5.966646952167348,
'cilo': 5.633353047832651,
'fliers': array([], dtype=float64),
'iqr': 1.3000000000000007,
'mean': 5.843333333333334,
'med': 5.8,
'q1': 5.1,
'q3': 6.4,
'whishi': 7.9,
'whislo': 4.3}]
Is there a way to extract the outlier shown in the boxplot?