0
0
Pandasdata~30 mins

Histogram plots in Pandas - Mini Project: Build & Apply

Choose your learning style9 modes available
Histogram plots
📖 Scenario: You work in a small bakery that tracks daily sales of different types of bread. You want to understand how many breads are sold each day to plan better for the next week.
🎯 Goal: Create a histogram plot to visualize the distribution of daily bread sales using pandas.
📋 What You'll Learn
Create a pandas DataFrame with daily sales data
Set a variable for the number of bins in the histogram
Use pandas to plot a histogram of the sales data
Display the histogram plot
💡 Why This Matters
🌍 Real World
Histograms help businesses understand how data like sales or customer visits are spread out over time.
💼 Career
Data scientists and analysts use histograms to visualize data distributions and find patterns or outliers.
Progress0 / 4 steps
1
Create the sales data
Create a pandas DataFrame called sales_data with one column named daily_sales containing these exact values: 12, 15, 7, 10, 20, 18, 5, 8, 15, 10.
Pandas
Need a hint?

Use pd.DataFrame and pass a dictionary with key "daily_sales" and the list of values.

2
Set the number of bins
Create a variable called num_bins and set it to 5 to decide how many bars the histogram will have.
Pandas
Need a hint?

Just create a variable num_bins and assign it the value 5.

3
Plot the histogram
Use the plot method on sales_data["daily_sales"] with kind="hist" and bins=num_bins to create the histogram plot.
Pandas
Need a hint?

Use sales_data["daily_sales"].plot(kind="hist", bins=num_bins) to create the histogram.

4
Show the histogram plot
Import matplotlib.pyplot as plt and call plt.show() to display the histogram plot.
Pandas
Need a hint?

Use import matplotlib.pyplot as plt and then plt.show() to display the plot window.