??Creating a Matplotlib Histogram

??Creating a Matplotlib Histogram

Create a histogram to analyze the distribution of customer spending per visit at a shopping mall, using 'mintcream' for low spenders, 'salmon' for medium spenders, and 'darkcyan' for high spenders.

This exercise will enhance your ability to work with categorical data, apply colour mapping, and generate clear, insightful charts.


Approach Hints

If you're solving this on your own, consider these technical points:


Grouping Data

  • Use df[df['spender_category'] == category] to filter the dataset by spending category.

Histogram Plotting

  • Use plt.hist() to create histograms with 20 bins for detailed distribution.

Colour Mapping

  • Assign colours to each spender category for better visual clarity.

Figure Size

  • Set figsize=(12, 6) for a well-proportioned visual.

Legend & Grid

  • Add a legend (plt.legend()) for category labels and enable plt.grid(True) for readability.


Take the challenge!


??? We’d Love Your Feedback!

We’re always looking to improve the content we share with you. Take a moment to fill out a quick survey and let us know your thoughts and any features you'd like to see on StrataScratch.


??? More Education Resources

Expand your knowledge with these insightful reads:

Learn the key differences between one-tailed and two-tailed hypothesis tests, when to use each, and how they impact statistical analysis.


Discover alternative Python libraries that go beyond pandas to help you handle larger datasets, optimise performance, and improve your data science workflows.

要查看或添加评论,请登录

StrataScratch的更多文章

社区洞察