w3resource

Creating a Scatter Plot with Pandas and Seaborn

Pandas: Visualization Integration Exercise-5 with Solution

Write a Pandas program to create a Box Plot with Pandas and Seaborn.

This exercise creates a box plot to visualize the distribution and outliers in a dataset using Pandas and Seaborn.

Sample Solution :

Code :

import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

# Create a sample DataFrame
df = pd.DataFrame({
    'Scores': [50, 55, 60, 65, 70, 75, 80, 85, 90, 100]
})

# Create a box plot of 'Scores'
sns.boxplot(y='Scores', data=df)

# Add a title
plt.title('Score Distribution Box Plot')

# Display the plot
plt.show()

Output:

Pandas - Creating a Histogram Plot with Pandas and Matplotlib

Explanation:

  • Created a DataFrame with 'Scores' data.
  • Used sns.boxplot() to create a box plot that visualizes the distribution of scores and highlights any outliers.
  • Added a title and displayed the plot.

Python-Pandas Code Editor:

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/python-exercises/pandas/create-a-box-plot-with-pandas-and-seaborn.php