roclark / sportsipy

A free sports API written for python
MIT License
475 stars 189 forks source link

NBA Boxscores not pulling with date #719

Open John8640 opened 2 years ago

John8640 commented 2 years ago

Lately I'm trying to pull NBA boxscore data with sportsipy for a list of dates in date_df with the following code:

def game_data_up_to_date(date_df):
    games_df1 = pd.DataFrame()
    for d in range(len(date_df)):
        date_string = date_df.iloc[d]['date']
        day_scores = Boxscores(pd.to_datetime(date_df.iloc[d]['date']))
        games_df = pd.DataFrame()
        for g in range(len(day_scores.games[date_string])):
            game_str = day_scores.games[date_string][g]['boxscore']
            game_stats = Boxscore(game_str)
            game_df = pd.DataFrame(day_scores.games[date_string][g], index = [0])

        games_df1 = pd.concat([games_df1,games_df]).reset_index().drop(columns = 'index') 

    return games_df1

The expected output is the boxscore for each date and game in the list

I think the issue is is when I call day_scores = Boxscores(pd.to_datetime(date_df.iloc[d]['date'])) Boxscores does not seem to be pulling the correct information which is causing the rest of the code to malfunction.

I am also uncertain if lines game_str = day_scores.games[date_string][g]['boxscore'] game_stats = Boxscore(game_str) are working since the previous line to get day_scores is not.

I have used sportsipy before and never had this issue. I recently updated to Spyder 5.1.5 on my Mac (OS Monterey 12.1) and I have the latest version of sportsipy installed. I'm not sure if this is simply a user error on my end or something with the package itself. This is my first post on Github, and I'm not really sure if I've provided the correct information or context. If there is anymore info I can provide, I'm more than happy :)