-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Processing game_pk information: PlayDetails.__init__() got an unexpected keyword argument 'violation' #204
Comments
Thanks for the heads up! Looks like there is another update to the mlb api and we will need to add that field to game details |
All good, appreciate it. Use this all the time, so kudos to ya'll. Great stuff! |
Hey KC! Any ETA on when ya'll will make this code fix? Thanks! |
@KCNilssen any ETA for the fix here? Thanks! |
I'm sorry I'll go ahead and fix this now |
Can you share your code? I have no issues with gamepk 717885 @mustseetv314 |
sure @Mattsface ill run it again and post code |
Code snipet plus 2 .csv attached: mlb_games.csv #Add Game Venue and Location Detail Initialize new columnsdf['venue_id'] = None for index, row in df.iterrows(): new_column_order = [ Check if all columns are included in new_column_orderassert set(new_column_order) == set(df.columns), "New column order does not match DataFrame columns" Reindex the DataFrame with the new column orderdf = df[new_column_order] Save the updated DataFrame back to a CSVupdated_csv_file = 'mlb_games_ready.csv' |
Function: #Function to get weather and venue for a given game_pk |
Adds Violation Class to PlayDetails. Fixes Issue #204
@mustseetv314 Your issue should be resolved now, let us know If you have any more issues |
@KCNilssen @Mattsface looks good now gents, appreciate it! Upgraded to: python-mlb-statsapi 0.5.17 and errors are now gone. |
Note: I'm using the latest version of:
python-mlb-statsapi 0.5.16
MLB-StatsAPI 1.7.1
This function broke after the topperformers class update 2 weeks ago:
For some game_pk's the information returns as expected, but for a few(errors below) I'm receiving a PlayDetails.init() error, and I can't find that class in the repository:
PlayDetails.init() got an unexpected keyword argument 'violation'
Code:
def get_game_info(game_pk):
mlb = mlbstatsapi.Mlb()
try:
game = mlb.get_game(game_pk)
venue_id = game.gamedata.venue.id
venue_name = game.gamedata.venue.name
venue_lat = game.gamedata.venue.location.defaultcoordinates.latitude
venue_long = game.gamedata.venue.location.defaultcoordinates.longitude
venue_elevation = game.gamedata.venue.location.elevation
venue_surface = game.gamedata.venue.fieldinfo.turftype
return venue_id, venue_name, venue_lat, venue_long, venue_elevation, venue_surface
except Exception as e:
print(f"Error processing game_pk {game_pk}: {e}")
return "None", "None", "None", "None", "None", "None"
ERROR(For example processing 2023-06-03 game_pk's):
717885
Error processing game_pk 717885: PlayDetails.init() got an unexpected keyword argument 'violation'
The text was updated successfully, but these errors were encountered: