Homework 2: Matplotlib and Data Visualization


These data visualizations were created for my introductory computer science course using Python. I chose to create data visualizations on NBA players because I watched a lot of basketball with my dad growing up. The purpose of this homework assignment was to familiarize ourselves with Matplotlib and CSV files.

Five Most Common Ages of NBA Players

In this pie chart, I wanted to look into the five most common ages of NBA players. The percentages displayed on the pie chart show the percentage each age constitutes out of the five ages. It is important to note that while these percentages add up to 100%, the ages of NBA players are not contained within these five numbers.

A big thank you to Umut Aplaydin for creating the CSV file. All of this data was sourced from Kaggle.

Player Performance

Player Performance

For my second plot, I created a grouped bar chart. Here, I analyzed a few statistics of specific NBA players. I used the data of their True Shooting %(TS%), 3 Point Attempt Rate(3PAr), Free Throw Attempt Rate(FTr) to see how they are performing. It is important to note that the statistics are not completely up to date. This was solely created based off of the data from the CSV file.

All of this data was also sourced from Kaggle.

If you are interested in learning what these statistics mean, below are some good articles to read more about these terms:

  1. True Shooting Percentage
  2. Basketball Glossary

The project instructions can be found here!
More datasets on the NBA 2020-2021 Season Player Stats can be found here.


Here are some helpful resources I used for this project:

  1. Corey Schafer’s Matplotlib Playlist
  2. Article on How to Create a Grouped Bar Chart with Pandas
  3. Video on How to Create a Grouped Bar Chart with Pandas
  4. CSV files and Pandas


View Github