Exploratory Data Analysis: How was Raptors’ Performance on Home and Away Games.

Haoyang Niu
7 min readMar 10, 2021

2020 is a year with sudden and drastic changes. The global pandemic created a huge influence on people’s life and the business mode, including the NBA. Since the first NBA player Rudy Gobert was tested positive for Covid-19 on March 11, the NBA shut down all the games for 4 months and restarted regular season on July 30th. The way to run a game had completely changed after July 30th, as all the games were conducted at Walt Disney World Resort near Orlando, and players stayed in the “bubble” for the whole season.

It is known that before the shut down, NBA players had to travel to different cities in the US to play away games, which also created a saying “home advantage” as the home team has certain advantages against the away team. However, after the league resumed the season, players no longer need to travel. Thus, the question arises: Did the teams perform differently before and after the Covid-19 shutdown? Are the teams’ performance influenced by the traveling? Are there any teams that have changed To answer these questions, I will explore and analyze the game data obtained from kaggle.com.

First, we need to import the 2019–2020 NBA game data set from Internet and make some data editing and cleaning work. There are originally 23 columns of data. To make it simpler for analysis, I deleted 7 of them, including game_ID, team_ID, season, etc.

After formatting, there are 16 columns, with the Date being datetime variable, and the rest being numbers or string.

  1. Did NBA teams perform differently in home and away games in 2019–2020 season? If yes, what could be the possible reasons?

To first play around with the data and get some understanding about different teams’ performance, I split the dataset into two data frames, the games before and after shut down. Then I select three teams: Lakers, Jazz, and Raptors to do further analysis. I use points scored per game by the team to make the model. To further split the data, I created two data frames for each team — one for home games and one for away games. Here are the line charts for the three teams.

Line Charts for Lakers home and away games

Line Charts for Jazz home and away games

Line Charts for Raptors home and away games

After creating these charts, I also calculate the average points for each team in home and away games, and it turns out that only Raptors shows an obvious difference in points between home and away games.

I then made two scatter plots to put all the points scored for all the home teams and away teams on the plots. And the results are shown below.

From the two scatter plot, we can tell that in general, there is no big difference in points between home and away teams. As a professional basketball league, NBA is doing great on making sure the teams always perform the best.

2. How did the team Raptors perform before and after the Covid-19 shutdown? Did traveling make them a better team at home?

Despite the general performance on most NBA teams remain stable in home and away games, Raptors, a team from Canada, has showed different performance in home and away games. This might be the reason that Raptors locates in Canada and needs to travel more distance than other teams in NBA, which potentially affects its performance.

To better analyze the Raptor games before and after the Covid-19 shutdown, I come up with more specific models to exam the hypothesis we made.

First, I split the two data frames for Raptors’ home and away games into four: the home and away games before the shutdown, and the home and away games after the games recovered.

Then I made four line charts for each of the frames.

The Home and Away Games for Raptors before Shutdown

The Home and Away Games for Raptors after Shutdown

After splitting the data, I found that the difference in points between home and away game is even bigger before the shutdown. Raptors scored average 115.9 points per home game but 110 points per away game before the shutdown. Surprisingly, that situation completely turned over after the team played in the “bubble”, as it scored 12 points more in away games. However, the scale of data for the games after shutdown is too small to make any reasonable conclusion. And because there is no longer traveling for teams after the shutdown, the influence of “home advantage” should be gone.

y

To better visualize the data, I made two new plots that combine the home and away games together. With blue line being the home game points, the yellow line is the away game points.

Also, I created a new variable called “Point Differences” for the data frame, which use the home/away team points to minus the other one. And the results are shown below.

It is pretty obvious that Raptors made bigger point differences when it’s at home, even though they had both 9 losses in total in home and away games.

3. Taking rebound and assist per game as possible KPIs, how was Raptors’ performance on in the home and away games?

Other than points, rebound and assist are also two factors that people often consider as key factors to win the game. Thus, I made two models to analyze Raptors’ performance on these two factors. Since the games after the shutdown had no difference in home and away games, I would not use them anymore.

The results show that there is no obvious evidence to prove Raptors did better on rebound or assist in home game than away games, but the average stats for home game are still slightly higher than the away games.

Here is the scatter plot for Raptors’s rebound (Blue is away game and coral is home game).

Here is the scatter plot for Raptors’s assist(Black is away game and red is home game).

4. In general, how did all the teams do after the games resumed?

Now we could say it’s pretty obvious that Raptors did perform differently in home and away games before the shutdown. However, I am also wondering in general, did all the team perform differently before and after the Covid-19 shutdown?

To answer that question, I created two new variables called total game points and total field goals, which add the two teams points and field goals together for each game. Then I made a scatter plot to see the outcome (Green points stand for the games before shutdown and red points for after).

Surprisingly, the teams actually scored better after the games resumed. On average, each game had 4 points more than before. This might be caused by some other factors, such as referees’ interference ,or players’ status getting better after the break.

In conclusion, Raptors is one of the major teams that performed differently in home and away games in 2019–2020 season before shutdown. And the Covid-19 shutdown did not influence the players as negative as I thought. There are still a lot of interesting topics to navigate and analyze about this special season. I hope this blog would intrigue more people to play data analysis in the NBA games.

--

--