This script allows you to download NBA player season stats for a specified season using the NBA API.
- Python 3.x
nba_apilibrarypandaslibrary
python -m venv venv
source venv/bin/activate
Ensure you have Python installed on your system. Then, install the required libraries using pip:
pip install nba_api pandas- Clone or download the script.
- Make sure you have the necessary libraries installed.
- Run the script using Python.
python nba_player_stats_downloader.pyBy default, the script downloads player stats for the 2023-24 NBA season. You can change the season by modifying the season parameter in the function call.
season: The NBA season for which you want to download player stats. Format:'YYYY-YY'. Default is'2023-24'.max_retries: Maximum number of retries in case of network errors. Default is5.
The script generates a CSV file containing player stats for the specified season. The file is saved in the directory specified by file_path with a filename containing the current date and time of execution.
- This script may take some time to execute, depending on the number of active NBA players and network conditions.
- Ensure that you have proper network connectivity to access the NBA API.
- Modify the
file_pathvariable to specify the directory where you want to save the output CSV file.
