118|PYTHON – Lebron’s Early Dominance

Benjamin_Lau
Wed, 24 Jan 2024 05:05:17 +0000
Challenges

BYU Student Author: @DylanKing, @Benjamin_Lau
Reviewers: @Marco, @Boston, @Carter_Lee
Estimated Time to Solve: 45 Minutes

We provide the solution to this challenge using:

Python

Go here to perform this challenge in Alteryx

Need a program? Click here.

Overview
You’ve been working in public accounting for years now and you have decided you have had enough. Somehow, someway, you have a connection with ESPN and are taking a once-in-a-lifetime opportunity as Stephen A. Smith’s co-host for the hit sports show, First Take. As a huge basketball fan, you want to prepare for your first day on the show when you will debate Lebron’s legacy. Using your data analytics background, you want to find and create stats to outsmart Stephen A.

Instructions

1. You want to focus all of your stats on LeBron James’ first stint with Cleveland which was from 2003-2010. The NBA has five major key stats: points, assists, rebounds, steals, and blocks. You want to create a new metric that displays Lebron’s overall dominance. Add up these five key stats to create a new column called Key Stats. Group by player and find what each player’s average was for this metric through the stated time period. Your output should have two columns: Player and Key Stats Avg. Sort by Key Stats Avg in descending order and round Key Stats Avg to two decimal places.

2. Next, you want to show Lebron’s consistent dominance at such a young age. Rather than looking at averages you want to look at totals for these key stats. For example, if you were to try and find the total points a player scored in a season, you would multiply the number of games they played by their average points per game. Once you calculate the totals for the key stats for each season and player, then calculate the total for each player during this time period. Create a ranking of players for each key stat. Additionally, calculate the total MVPS for each player during this time period and create a ranking of players based on how many MVPs they won. After compiling all of this information, create an output that shows Lebron’s name with all of his totals and rankings across these six categories: points, assists, rebounds, steals, blocks, and MVPs.

3. Lastly, you want to emphasize that although Lebron lacked quality help, he was able to have consistent team success. Calculate each team’s average winning percentage from 2003-2010 (consistent with the time period we have been using). Round the average winning percentage to three decimal places and rank the teams in order from highest winning percentage to lowest winning percentage. Your output should have three columns: Average Winning Percentage Rank, Team, and Average Winning Percentage. Only show Lebron’s team which was the Cavaliers (your output should only have one row).

Data Files

Challenge118_NBA_Player_Stats.csv

Challenge118_Historical_NBA_Performance.xlsx

Challenge118_Data_Dictionary.docx

Suggestions and Hints (click for more details)
Solution

spoiler

2 posts - 2 participants

Read full topic