sportsipy
sportsipy copied to clipboard
'Boxscore' object has no attribute '_away_skaters' on some boxscore objects
Describe the bug I am getting this "AttributeError: 'Boxscore' object has no attribute '_away_skaters'", when running the sample code below. It's not happening with every boxscore, as the first 71 boxscores of the sample code are going through fine.
To Reproduce Sample code which causes an issue.
for team in Teams():
for game in team.schedule:
boxscore = game.boxscore
d = {'arena':[boxscore.arena],'attendance':[boxscore.attendance] ,
'away_assists':[boxscore.away_assists] ,'away_even_strength_assists':boxscore.away_even_strength_assists,
'away_game_winning_goals' :[boxscore.away_game_winning_goals], 'away_goals':[boxscore.away_goals],
'away_penalties_in_minutes':[boxscore.away_penalties_in_minutes],
'away_points':[boxscore.away_points], 'away_power_play_assists':[boxscore.away_power_play_assists],
'away_power_play_goals':[boxscore.away_power_play_goals], 'away_save_percentage':[boxscore.away_save_percentage],
'away_saves':[boxscore.away_saves], 'away_shooting_percentage':[boxscore.away_shooting_percentage],
'away_short_handed_assists':[boxscore.away_short_handed_assists],'away_short_handed_goals':[boxscore.away_short_handed_goals],
'away_shots_on_goal':[boxscore.away_shots_on_goal],'away_shutout':[boxscore.away_shutout],'duration':[boxscore.duration],
'home_assists':[boxscore.home_assists],'home_even_strength_assists':[boxscore.home_even_strength_assists],
'home_even_strength_goals':[boxscore.home_even_strength_goals], 'home_game_winning_goals':[boxscore.home_game_winning_goals],
'home_goals':[boxscore.home_goals],'home_penalties_in_minutes':[boxscore.home_penalties_in_minutes],
'home_points':[boxscore.home_points],'home_power_play_assists':[boxscore.home_power_play_assists],
'home_power_play_goals':[boxscore.home_power_play_goals], 'home_save_percentage':[boxscore.home_save_percentage],
'home_saves':[boxscore.home_saves],'home_shooting_percentage':[boxscore.home_shooting_percentage],
'home_short_handed_assists':[boxscore.home_short_handed_assists],'home_shots_on_goal':[boxscore.home_shots_on_goal],
'home_shutout':[boxscore.home_shutout],'losing_abbr':[boxscore.losing_abbr],
'losing_name':[boxscore.losing_name], 'playoff_round':[boxscore.playoff_round],
'time':[boxscore.time],'winner':[boxscore.winner],
'winning_abbr':[boxscore.winning_abbr],'winning_name':[boxscore.winning_name]
}
df = pd.DataFrame(d)
Expected behavior No ValueError like the previous sets.
Screenshots
Desktop (please complete the following information):
- OS: Windows 10, python 3.7.1
- Sportsreference Version 0.5.2
When iterating through teams and boxscores like this, it's the 71st Boxscore Item of the Boston Bruins where the boxscore.away_assists item is not existing, like other attributes, I am assuming.
Figured out what the problem is, I guess, and I think it might be a corona problem. The last game the Boston Bruins played was on 10th of March. I didn't check your source code but I think it might be that it only checks when the games were scheduled and if it is in the past. And if so, it tries to get the boxscore. If the game did not happen, there is still a boxscore item, but it is completely empty, except for the date. So you might need a check, whether the game really happened or not before creating a boxscore item or before even creating the game in team.schedule