Closed pferreira8 closed 1 year ago
I have added a try-catch to circumvent this error, it now works in this context, just occasionally triggers that TypeError above. I am willing to help contribute to fixing this issue.
after running the loop over the 2023 season to this date, the only gameID that contained an error was 719391
The issue is that Tyler Brown playing for Minnesota here doesn't have a position field. How the dataclass is currently set up requires a position field. This should be an easy fix to make. We will just make position an optional field and that would fix this issue.
"ID675973": {
"person": {
"id": 675973,
"fullName": "Tyler Brown",
"link": "/api/v1/people/675973"
},
"jerseyNumber": "93",
"status": {
"code": "MIN",
"description": "Minor League Contract"
},
"parentTeamId": 117,
"stats": {},
"seasonStats": {},
"gameStatus": {}
},
Stats, seasonStats, and gameStatus are empty here just to save space while showing you the structure. They are all populated correctly in the real return.
Here is the api endpoint for the boxscore for that specific game: https://statsapi.mlb.com/api/v1/game/719391/boxscore
This should fix your issue. Thanks for the heads up!
I've attached a screenshot of my traceback, the issue is related to PlayerDictsPerson.init()
I call this function in my if name == main block, and then try to pass the boxscores list into a pd Dataframe after. I am looping through a series of game Ids to try and accomplish this, which is the ["gamepk"] pandas Series ` def get_box_scores(self): boxscores = [] for g in self.game_df["gamepk"]: box = self.api.get_game_box_score(int(g)) boxscores.append(box)
all boxscores of season df
` It works however if I do a static call like this, Mlb().get_game_box_score(1234556)