We provide the solution to this challenge using:
Need a program? Click here.
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.
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.
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.
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).
Suggestions and Hints
- Consider using pandas Dataframes to solve this problem.
- When you are solving this, try to use display(df.head()) throughout the process to see if you are getting what you want to get with the codes.
- Google or ChatGPT code suggestions as this is often what coders do. Do not feel guilty about using these valuable resources.