0
0
Pandasdata~30 mins

Scatter plots in Pandas - Mini Project: Build & Apply

Choose your learning style9 modes available
Scatter plots
📖 Scenario: You work as a data analyst for a small company that sells different products. You have collected data about the price and sales of each product. You want to see if there is any relationship between the price of a product and how many units it sells.
🎯 Goal: You will create a scatter plot using pandas to visualize the relationship between product prices and sales.
📋 What You'll Learn
Create a pandas DataFrame with product data
Add a variable for the size of the scatter points
Use the DataFrame to create a scatter plot with price on the x-axis and sales on the y-axis
Display the scatter plot
💡 Why This Matters
🌍 Real World
Scatter plots help visualize relationships between two numeric variables, like price and sales, to find patterns or trends.
💼 Career
Data analysts and scientists use scatter plots to explore data and communicate insights clearly to teams and decision makers.
Progress0 / 4 steps
1
Create the product data
Create a pandas DataFrame called products with these exact columns and values:
'Product': ['Pen', 'Notebook', 'Eraser', 'Pencil', 'Marker']
'Price': [1.5, 3.0, 0.5, 1.0, 2.0]
'Sales': [100, 80, 150, 120, 90]
Pandas
Need a hint?

Use pd.DataFrame with a dictionary where keys are column names and values are lists of data.

2
Add a size variable for points
Create a variable called sizes that contains the Sales column from the products DataFrame multiplied by 2. This will be used to set the size of the scatter plot points.
Pandas
Need a hint?

Use products['Sales'] to get the sales column and multiply it by 2.

3
Create the scatter plot
Use the plot.scatter method on the products DataFrame to create a scatter plot with x='Price', y='Sales', and s=sizes to set the point sizes.
Pandas
Need a hint?

Use products.plot.scatter(x='Price', y='Sales', s=sizes) to create the scatter plot.

4
Display the scatter plot
Use import matplotlib.pyplot as plt and then call plt.show() to display the scatter plot.
Pandas
Need a hint?

Import matplotlib.pyplot as plt and call plt.show() to display the plot window.