Closed cjwin2000 closed 1 year ago
Update:
I'm pretty confident I found the issue. I added in a line to log the raw stats response in player.py
and the response contains data from both the 2023 and 2022 seasons. I have attached the response to this comment. Whenever there is a scoringPeriodId
of equal value for both seasons, it prefers the 2022 season data, and it will list all unique scoringPeriodId
s when using this API causing there to be too many keys. There should be however many team games have been played plus two--one for average and one for projections I'm guessing since these both have scoringPeriodId=0
. Going back to my example of the first game of the season with scoringPeriodId=3
, you'll see that the incorrect data I mentioned above is just the data from that same scoringPeriodId
from the 2022 season. In fact, if you don't sort the scoringPeriodId
s like I did above, you'll see they're in the proper order (most recent game first), with the 2022-only (thus far) keys appended at the end.
Apologies for the json being in a zip. Github limitations 🙃
Created a pull request to fix this. I don't fully understand what's going on so hopefully that doesn't break any other functionality.
Some of the records in the response don't even have the "total" key that should allow users to access fields like points and rebounds for specific games. The code snippet below actually fails eventually for this reason. Some of the values, however are correct
Ignore this. I am an idiot and didn't realize this was due to the player sitting out the game. In my testing everything stats-related for players seems to be working correctly.
Thanks for digging into this and creating a PR! I will check it out now and see if I get the same results! We had a similar issue in the football class and had to filter out other years in player class here
PR has been merged and is in the latest v0.28.1 package! Thanks for all the help!
Sport
Basketball
Summary
The stats dictionary from the player class seems to be broken. The code below uses a playerId (Luka Doncic) and prints the sorted list of games (keys) from the player's schedule and then from their stats. It then prints the intersection of these lists, which in theory should be identical lists of 82 games. I removed the final two entries from the stats due to those keys being for averages and predictions. The data from the schedule seems to be correct (82 games that line up with the Mavericks' schedule), but the data from the stats is inconsistent.
There are more than the proper 82 games listed. For example, even though the stats list '5' as a key, the Mavericks did not play on the fifth day of the season, and the schedule omits this key correctly. Also, the stats for the keys where the player did play are wrong sometimes. For example the output from the code below shows that in the first game of the season (key of 3), Doncic had 18 points and 29 fantasy points. In reality, he had 35 points and 40 fantasy points. Some of the records in the response don't even have the "total" key that should allow users to access fields like points and rebounds for specific games. The code snippet below actually fails eventually for this reason. Some of the values, however are correct. His most recent game (key 57) looks to be accurate. Any idea if this is something on my end or a bug with the API? I have included the output I am getting below the code. I should also mention this happens for multiple players, I am just using Doncic as an example.
Code:
Output:
Logs/Data
No response