# Understanding Python pandas.DataFrame.boxplot

In this tutorial, we’ll learn about data visualization using the BoxPlot with Pandas in Python.

This method is used to illustrate the different groups of numerical data through their quarterlies. It represents the summary of data with a simple box. In this way, we can compare different groups of data with each other.

A box plot is consists of the followings:

- Minimum
- First Quartile or 25%
- Second Quartile or 50%
- Third Quartile or 75%
- Maximum

The dataset is of a restaurant that contains the following details Total_bill, Tip, Sex, Smoker, Day, Time, and Size of 1708 different groups of customers.

We’ll analyze the different parameters like Total_bill, size, etc. grouped on the basis of Day.

First, we’ll import the following packages:

import numpy as np import pandas as pd import matplotlib.pyplot as plt % matplotlib inline

Now, we’ll read the dataset using pandas.

df = pd.read_csv("party.csv") df.head()

The first rows of the dataset are as follows:

Now, display the Boxplot of Day with respect to tip.

df.boxplot(by ='day', column =['tip'], grid = False)

Its corresponding result is as follows:

Now, display the Boxplot of Day with respect to total_bill.

df.boxplot(by ='day', column =['total_bill'], grid = False)

Its corresponding result is as follows:

Now, display the Boxplot of Day with respect to size.

df.boxplot(by ='day', column =['size'], grid = False)

Its corresponding result is as follows:

I hope you enjoyed this tutorial.

Also read: DataFrame, date_range(), slice() in Python Pandas library

## Leave a Reply