Skip to content
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

CumeStatsPlayer does not work. #309

Open
YKhanTU opened this issue Nov 13, 2022 · 4 comments · May be fixed by #437
Open

CumeStatsPlayer does not work. #309

YKhanTU opened this issue Nov 13, 2022 · 4 comments · May be fixed by #437
Labels
documentation Documentation is needed or requires an update enhancement New feature or request

Comments

@YKhanTU
Copy link

YKhanTU commented Nov 13, 2022

CumeStatsPlayer doesn't seem to be working properly.

It requires a list of GameIDs, which are provided when I fetch all game IDs for a certain player's season (in this case, Jason Tatum 2021-22). Despite giving a ton of GameIDs, I only get the totals for 1 game? I am confused. It even says GP/GS are both values of 1 in the response.

Below is what I am executing:

from nba_api.stats.endpoints import commonplayerinfo, cumestatsplayer, cumestatsplayergames
from nba_api.stats.static import players;

# nba_players = players.get_players()
nba_players = players.find_players_by_full_name('Jayson Tatum')

for nba_player in nba_players:
    player_id = nba_player['id']

    player_info = commonplayerinfo.CommonPlayerInfo(player_id).common_player_info.get_dict()

    p_columns = player_info['headers']
    p_rows = player_info['data'][0]

    p_data = dict(zip(p_columns, p_rows))

    print(p_data)

    p_games = cumestatsplayergames.CumeStatsPlayerGames(player_id, league_id='00', season='2021-22', season_type_all_star='Regular Season').cume_stats_player_games.get_dict()['data']

    game_ids = []

    for game in p_games:
        game_ids.append(game[1])
    
    print(game_ids)

    p_stats = cumestatsplayer.CumeStatsPlayer(player_id, game_ids, league_id='00', season='2021-22').total_player_stats.get_dict()

    pstats_columns = p_stats['headers']
    pstats_rows = p_stats['data'][0]

    pstats_data = dict(zip(pstats_columns, pstats_rows))

    print('\n\n')
    print('player stats: ')
    print(pstats_data)

Even putting hand-picked game IDs into the game_ids parameter gives me the same result, cumulative stats for only 1 game despite giving a bunch of game IDs that are valid.

@rsforbes rsforbes added the triage Researching into a possible bug label Nov 13, 2022
@rsforbes
Copy link
Collaborator

@YKhanTU: The game_ids should be formatted as 0022200186|0022200176|0022200163|0022200152

Here's a valid URL:

https://stats.nba.com/stats/cumestatsplayer?LeagueID=00&Season=2022-23&SeasonType=Regular Season&PlayerID=1628369&gameIDs=0022200186|0022200176|0022200163|0022200152

Actual Site: https://www.nba.com/stats/cumestats?ReportType=Player&PlayerID=1628369

You can use the browsers Dev Tools to view the call.

All that being said, I think we could certainly make this more clear, or put in an option that simply takes a dictionary in; that would have been my first thought.

Hope that helps.

@rsforbes rsforbes added enhancement New feature or request documentation Documentation is needed or requires an update and removed triage Researching into a possible bug labels Nov 14, 2022
@YKhanTU
Copy link
Author

YKhanTU commented Nov 16, 2022

@YKhanTU: The game_ids should be formatted as 0022200186|0022200176|0022200163|0022200152

Here's a valid URL:

https://stats.nba.com/stats/cumestatsplayer?LeagueID=00&Season=2022-23&SeasonType=Regular Season&PlayerID=1628369&gameIDs=0022200186|0022200176|0022200163|0022200152

Actual Site: https://www.nba.com/stats/cumestats?ReportType=Player&PlayerID=1628369

You can use the browsers Dev Tools to view the call.

All that being said, I think we could certainly make this more clear, or put in an option that simply takes a dictionary in; that would have been my first thought.

Hope that helps.

Awesome. I didn't realize it needed to be formatted in that way. That would be nice if we could pass in an array or dictionary in as well.

Thanks for the help.

@Jimmay13
Copy link

Jimmay13 commented Dec 3, 2022

I am having trouble even using one game id. I tried multiple ones with the format you suggested and it also does not work. This line returns an error.
from nba_api.stats.endpoints import cumestatsplayer
cumestatsplayer.CumeStatsPlayer(game_ids='22001069', player_id=1630173, season='2020-21', season_type_all_star='Regular Season')

I tried just using the game_ids as a single value thats not a string. I tried using your format hoping multiple games would return something like so : game_ids='22001069|22001062'.

I have had no other trouble with your other endpoints I have used so far.

Here is the error that comes up.

Traceback (most recent call last):
File "", line 1, in
File "/Users/jamesordaya/.local/lib/python3.9/site-packages/nba_api/stats/endpoints/cumestatsplayer.py", line 38, in init
self.get_request()
File "/Users/jamesordaya/.local/lib/python3.9/site-packages/nba_api/stats/endpoints/cumestatsplayer.py", line 48, in get_request
self.load_response()
File "/Users/jamesordaya/.local/lib/python3.9/site-packages/nba_api/stats/endpoints/cumestatsplayer.py", line 51, in load_response
data_sets = self.nba_response.get_data_sets()
File "/Users/jamesordaya/.local/lib/python3.9/site-packages/nba_api/stats/library/http.py", line 83, in get_data_sets
raw_dict = self.get_dict()
File "/Users/jamesordaya/.local/lib/python3.9/site-packages/nba_api/library/http.py", line 41, in get_dict
return json.loads(self._response)
File "/Users/jamesordaya/.conda/envs/pythonProject1/lib/python3.9/json/init.py", line 346, in loads
return _default_decoder.decode(s)
File "/Users/jamesordaya/.conda/envs/pythonProject1/lib/python3.9/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/Users/jamesordaya/.conda/envs/pythonProject1/lib/python3.9/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

@kterusaki
Copy link

At least of now, it's probably best to update the documentation for this endpoint. It's unclear that the required input format is 1. a string and 2. the string needs to follow the format 'game_id_0|game_id_1|game_id2'.

Secondly, this is probably an implementation detail that can be handled by the CumeStatsPlayer endpoint and just expect a list or a set as input to the game_ids parameter.

@TylerChasse TylerChasse linked a pull request Apr 11, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Documentation is needed or requires an update enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants