You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Traceback (most recent call last):
File "C:/Test.py", line 16, in
game_list_2019 = statsapi.schedule(start_date=start_date, end_date=end_date)
File "C:\Users\Philconow\AppData\Local\Programs\Python\Python37\lib\site-packages\statsapi_init_.py", line 161, in schedule
'winning_pitcher': game['decisions'].get('winner',{}).get('fullName',''),
KeyError: 'decisions'
The text was updated successfully, but these errors were encountered:
philconow
changed the title
Getting an error
Error: 'winning_pitcher': game['decisions'].get('winner',{}).get('fullName',''), KeyError: 'decisions'
Jun 27, 2019
This happened because the decisions field is missing in the MLB data for a game. I thought MLB included the decisions field for all completed games, but perhaps there was a suspended game or something else out of the ordinary for which they leave that field out. I’ll take a closer look later today or tomorrow.
The fix is easy regardless of why the data is not included. I just have to change game[‘decisions’] to game.get(‘decisions’,{}) to account for the field missing sometimes.
It's due to gamePk 565060 from 6/13 not having the decisions data included, but I don't see anything special about that game. It completed after 8.5 innings, the status is FInal, and the Red Sox beat the Rangers 7-6. MLB Gameday shows W/L/S in the pitching box score, but it is also missing a couple of names for the Red Sox (no name on the row after Brewer, and no name with the save credited). I'll add protection against missing decision data, but I don't know why it's missing.
I ran the following with version 0.0.8 which was running fine a few weeks ago:
And get back this error:
The text was updated successfully, but these errors were encountered: