NBA

NBA games that ended with the same score on the same day

Yesterday, during Round of 16 of the FIBA EuroBasket 2022, three matches ended with the same score, 94-86.

I wanted to see if this has happened before in the tournament. I couldn't find a data set and scraping the results wasn't as straightforward as I thought. So, I turned to NBA instead.

I downloaded the [Basketball Dataset](https://www.kaggle.com/datasets/wyattowalsh/basketball) from Kaggle, that contains data on every game since the first NBA season in 1946-47.

The data set is actually an SQLite database, so I used the RSQLite package to read the file and get a list of the tables:

library(RSQLite)
library(tidyverse)
con <- dbConnect(drv = RSQLite::SQLite(), dbname = "nba.sqlite")
tables <- dbListTables(con)
tables <- tables[tables != "sqlite_sequence"]

There are 16 tables, the one with the game results is Game

tables
 [1] "Draft"                 "Draft_Combine"         "Game"                 
 [4] "Game_Inactive_Players" "Game_Officials"        "News"                 
 [7] "News_Missing"          "Player"                "Player_Attributes"    
[10] "Player_Bios"           "Player_Photos"         "Player_Salary"        
[13] "Team"                  "Team_Attributes"       "Team_History"         
[16] "Team_Salary" 

The next step was to get just the Game table:

games <- dbGetQuery(conn=con, statement=paste("SELECT * FROM 'Game'", sep=""))

I cleaned the variable names and selected the columns of interest, then remove duplicate rows:

scores <- games %>% 
  janitor::clean_names() %>% 
  select(game_id, game_date, team_name_home, team_name_away, pts_home, pts_away) %>% 
  distinct()

In order to count the same scores for each date, I created a new column with each game’s score as a sorted list. That means that two games that ended, for example, with 86-64 and 64-86, appear in the same way, as c(86, 64).

The final step was to add a count of scores by date and sort it:

score_counts <- scores %>% 
  rowwise() %>% 
  mutate(score = list(sort(c(pts_home, pts_away)))) %>% 
  ungroup() %>% 
  add_count(game_date, score, sort = TRUE)

It looks like that the same score has appeared three times on the same day only once, on March 5, 2003. That’s one date of the 11,015 dates in the database. If we consider only dates with three or more games, it is 1 in 9,079, or 0.01%.