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

Unable to get stats for current season #52

Closed
AnkitPatanaik opened this issue Nov 17, 2018 · 5 comments
Closed

Unable to get stats for current season #52

AnkitPatanaik opened this issue Nov 17, 2018 · 5 comments

Comments

@AnkitPatanaik
Copy link

AnkitPatanaik commented Nov 17, 2018

When trying to make a call getting data for the current season (season ending in 2019), I receive the following error:

Traceback (most recent call last):
  File "compare.py", line 25, in <module>
    print(get_stats(get_values(["Joe Harris", "Kevin Durant"])))
  File "compare.py", line 8, in get_values
    players = client.players_season_totals(2019)
  File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/basketball_reference_web_scraper/client.py", line 35, in players_season_totals
    values = http_client.players_season_totals(season_end_year)
  File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/basketball_reference_web_scraper/http_client.py", line 66, in players_season_totals
    return parse_players_season_totals(response.content)
  File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/basketball_reference_web_scraper/parsers/players_season_totals.py", line 43, in parse_players_season_totals
    totals.append(parse_player_season_totals(row))
  File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/basketball_reference_web_scraper/parsers/players_season_totals.py", line 9, in parse_player_season_totals
    "position": POSITION_ABBREVIATIONS_TO_POSITION[row[2].text_content()],
KeyError: 'F-G'```
@jaebradley
Copy link
Owner

jaebradley commented Nov 17, 2018

@AnkitPatanaik thanks for reporting this issue

It looks like Basketball Reference added the F-G position value for Jimmy Butler's 2018-2019 Philadelphia 76ers season totals.

image

This is the first time I've seen this position value used for a player's season totals (usually, the multi-position values are used when a player has played multiple positions across multiple teams).

#53 should fix this - I'll close this issue when the patch version has been published to PyPi.

@AnkitPatanaik
Copy link
Author

Awesome! Thanks a lot :)

jaebradley added a commit that referenced this issue Nov 17, 2018
Resolves #52 - Jimmy Butler's 2018 Phildelphia 76ers Season Totals include the position value `F-G`. 

Normally, it's seemed that a player's season total position values for a particular team are limited to a single position.

Only when a player has played multiple positions for multiple teams over a given season are multiple positions indicated for that player, and only for the player's overall season total row.

Going forward, it might be better to parse that field as a list, if this trend continues.

However, this would be a breaking change and would need to be a major version upgrade.
@jaebradley
Copy link
Owner

@AnkitPatanaik After installing v3.1.1, I hope your issue has been resolved. Please re-open if that's not the case.

@AnkitPatanaik
Copy link
Author

AnkitPatanaik commented Nov 17, 2018

Hey @jaebradley, I tried install version 3.1.1 but pip was unable to find the updated version. Maybe I'm doing something wrong?

~/dev/fantasy-bball(branch:master*) » pip install basketball_reference_web_scraper==3.1.1
Collecting basketball_reference_web_scraper==3.1.1
  Could not find a version that satisfies the requirement basketball_reference_web_scraper==3.1.1 (from versions: 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1)
No matching distribution found for basketball_reference_web_scraper==3.1.1

EDIT: looks like I had an outdated version of pip

@AnkitPatanaik
Copy link
Author

It looks like there are some other positions that are not accounted for:

Traceback (most recent call last):
  File "compare.py", line 40, in <module>
    main()
  File "compare.py", line 37, in main
    team1_players = get_values(team_1)
  File "compare.py", line 11, in get_values
    players = client.players_season_totals(YEAR_END)
  File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/basketball_reference_web_scraper/client.py", line 35, in players_season_totals
    values = http_client.players_season_totals(season_end_year)
  File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/basketball_reference_web_scraper/http_client.py", line 66, in players_season_totals
    return parse_players_season_totals(response.content)
  File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/basketball_reference_web_scraper/parsers/players_season_totals.py", line 43, in parse_players_season_totals
    totals.append(parse_player_season_totals(row))
  File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/basketball_reference_web_scraper/parsers/players_season_totals.py", line 9, in parse_player_season_totals
    "position": POSITION_ABBREVIATIONS_TO_POSITION[row[2].text_content()],
KeyError: 'F'

I would presume there might be combinations like "F-C" and "G" as well but I am yet to confirm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants