what-is-a-boxplot

How to plot Boxplot in Python

A box plot is used to visualize 5 values in a dataset for the selected column(s):

  • Minimum Value
  • First Quartile or 25%
  • Median (Second Quartile) or 50%
  • Third Quartile or 75%
  • Maximum value

Box Plot is also known as Box and Whisker Plot.

Steps –

    1. Load the dataset using Pandas dataframe
  1. Select any column to visualize
  2. Plot boxplot using Pandas
    OR
  3. Plot boxplot using Seaborn

Python Code :

import pandas as pd

#load data

data = pd.read_csv(‘insurance.csv’)

data.head(10)

how to plot boxplot in pandas

>> data.describe()

statistics in python pandas

# 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
data.boxplot(column=[‘age’],figsize=[10,7])

# We can group data as well.

data.boxplot(column=[‘age’], by=[‘gender’], figsize=[10,7])

Boxplot Using Seaborn Library

Leave a Comment