farazjawed's picture
Update README.md
ecc240a verified
metadata
pretty_name: NBA Play by Play Data for 2023 season
license: mit

Source of the data: Sportsradar API (https://developer.sportradar.com/docs/read/basketball/NBA_v8)

NBA Play-by-Play Data Extraction and Analysis

Overview

This project aims to retrieve play-by-play data for NBA matches in the 2023 season using the Sportradar API. The play-by-play data is fetched from the API, saved into JSON files, and then used to extract relevant features for analysis and other applications. The extracted data is saved in Parquet files for easy access and usage by others.

Features

The project provides the following features:

  • Fetching play-by-play data for NBA matches in the 2023 season from the Sportradar API.
  • Saving the fetched data into JSON files for archival and offline use.
  • Extracting relevant features from the JSON files, such as:
    • Match date and time
    • Home team and away team information
    • Play descriptions
    • Clock time
    • Event types (e.g., two-pointer, three-pointer, block, foul)
    • Home team points and away team points
    • Quarter number
  • Saving the extracted data into Parquet files for easy access and analysis.

Format

  • The data is in the form of .parquet files, with each file corresponding to one NBA game. We have data on a total of 179 NBA games in the 2023 season, this was the highest limit available on the Sportsradar API free tier.
  • There is also a file called _combined_dataframe.parquet which has data for all of the games in one file, incase someone wants to use that.

Data Pipeline Code

  • The file api_fetch.ipynb contains the code which was used to fetch data and create the source json files for each of the matches which were then used for creating clean parquet files having the relevant data which we need.
  • If you need to look at a specific example of the json file you can do so by going in the json_example folder. It has the raw json data fetched for one example game. For full access of json files for each game (incase you want more data - on each player level or something, please reach out on [email protected]).

Explanation of my code in dataset_creation.ipynb

  1. Fetching Play-by-Play Data: To fetch play-by-play data, I made the function get_game_pbp() function, which retrieves data from the Sportradar API and saves it into JSON files.

  2. Extracting Features: Used the get_game_pbp() function to extract relevant features from the JSON files and create a DataFrame containing the extracted data.

  3. Saving Data: The extracted data can be saved into Parquet files using pandas' to_parquet() function for future analysis and usage.

How can you use it:

Run the following commands:

  • from datasets import load_dataset

  • dataset = load_dataset("farazjawed/NBA_PLAY_BY_PLAY_DATA_2023")

Potential Applications

  • Generating live commentary for NBA matches.
  • Performing in-depth analysis of player performance, team strategies, and game dynamics.
  • Developing predictive models for match outcomes or player performance.

Contributors

  • [Faraz Jawed] - Project Lead & Developer

License

This project is licensed under the MIT License.