A box plot is used to visualize 5 values in a dataset for the selected column(s):
Box Plot is also known as Box and Whisker Plot.
Python Code :
import pandas as pd
data = pd.read_csv(‘insurance.csv’)
# In pandas boxplot one attribute, column is required to plot boxplot
# Column can take name of one column of the dataset or the list of columns
# We can group data as well.
data.boxplot(column=[‘age’], by=[‘gender’], figsize=[10,7])
# import the library seaborn as sns
import seaborn as sns
from matplotlib import pyplot as plt
#set the style of seaborn as whitegrid
# Seaborn takes minimum of 2 attributes to plot a boxplot
# x = name of column and data = dataframe
What is Outlier in Boxplot ?
Outlier – if a data point is below Q1 – 1.5×IQR or above Q3 + 1.5×IQR
Here IQR is the interquartile range, which you can see in the featured image.