__STYLES__

NBA Payroll Efficiency Analytics

Tools used in this project
NBA Payroll Efficiency Analytics

About this project

The Project

This project was a passion project created out of my love for basketball and the NBA. My goal was to answer two questions:

  1. "Do teams that spend more win more championships?"
  2. "Do teams that spend more win more games?"
  3. "Which teams spend their money most efficiently?"

Doing all of this involved web scraping, using the NBA_API, Docker to setup a Postgres SQL database, and Power BI to create the visuals.

All of the code for this project can be found at my Github: NBA Payroll Project

Database Creation

I wanted to put all of the data into a SQL database so that Power BI could easily connect to it. This is where Docker came in, so to start the project, I created my docker-compose.yml file.

Data Collection

Now that the docker compose file is created, its time to get the data. There are two datasets we need. First, we need yearly payroll data for each team. Second, we need year by year statistics. This will include standings and finals appearances.

Yearly Payroll Data Web Scrape

I couldn't find an API that had yearly payroll data, so I had to scrape it. This ended up being fairly easy. I found the data at Hoops Hype. I simply used the BeautifulSoup library to scrape the data from the site.

Once I had scraped the data, I used pandas .tosql and SQLalchemy to upload the database to the PostgresSQL database I created earlier.

Year by Year Statistics API Pull

For this dataset, I was able to use the NBA_API teamyearbyyearstats endpoint. This made it very simple to pull the data. Again I uploaded it to the SQL database and moved on to creating the visuals.

Power BI Dashboard

To create the visuals, I simply connected Power BI to the locally hosted SQL database, and then used Power Query to merge the payroll data, onto the year by year data. This let me begin creating the visuals you see in the featured screenshot.

Additional project images

Discussion and feedback(0 comments)
2000 characters remaining