Closed leonv79 closed 3 months ago
from nba_api.stats.static import teams
from nba_api.stats.endpoints import leaguegamefinder
import pandas as pd
list_of_games = []
nba_teams = teams.get_teams()
team_ids = [team['id'] for team in nba_teams]
for id in team_ids:
gamefinder = leaguegamefinder.LeagueGameFinder(team_id_nullable=id)
games = gamefinder.get_data_frames()[0]
list_of_games.append(games)
final_df = pd.concat(list_of_games, ignore_index=True)
game_ids = list(set(final_df['GAME_ID']))
This will get you basically every game that the API has available. You can further filter the dataframe by date, team, etc. Enjoy!
You saved me so much time, thanks a lot!
Hi! I'm kinda new here so i'm a bit unfamiliar with the package. First of all the work that has been done is terrific. Really useful stuff. Now to my problem. I see that you can find player and team ids pretty easy on the static folder, but what about the game_ids? I want to gather all stats for a season in boxscorehustlev2 and it only requires game_ids. Any help would be really useful. Thanks in advance!