dcstats / CBBpy

A Python-based web scraper for NCAA basketball.
MIT License
11 stars 2 forks source link

Error logged - ValueError: invalid literal for int() with base 10: '--' (game ID 400915769) #12

Closed dcstats closed 1 year ago

dcstats commented 2 years ago

Code

s.get_game_boxscore('400915769')

Traceback

ERROR:scrape:"Thu Sep  8 18:00:26 2022" attempt 3: 400915769 - invalid literal for int() with base 10: '--'
Traceback (most recent call last):
  File "/Users/dscow/Documents/Projects/CBBpy/testing/espn/mens/scrape.py", line 136, in get_game_boxscore
    df_home = _clean_boxscore_table(
  File "/Users/dscow/Documents/Projects/CBBpy/testing/espn/mens/scrape.py", line 591, in _clean_boxscore_table
    df['min'] = df['min'].astype(int)
  File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.9/site-packages/pandas/core/generic.py", line 5912, in astype
    new_data = self._mgr.astype(dtype=dtype, copy=copy, errors=errors)
  File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.9/site-packages/pandas/core/internals/managers.py", line 419, in astype
    return self.apply("astype", dtype=dtype, copy=copy, errors=errors)
  File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.9/site-packages/pandas/core/internals/managers.py", line 304, in apply
    applied = getattr(b, f)(**kwargs)
  File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.9/site-packages/pandas/core/internals/blocks.py", line 580, in astype
    new_values = astype_array_safe(values, dtype, copy=copy, errors=errors)
  File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.9/site-packages/pandas/core/dtypes/cast.py", line 1292, in astype_array_safe
    new_values = astype_array(values, dtype, copy=copy)
  File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.9/site-packages/pandas/core/dtypes/cast.py", line 1237, in astype_array
    values = astype_nansafe(values, dtype, copy=copy)
  File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.9/site-packages/pandas/core/dtypes/cast.py", line 1154, in astype_nansafe
    return lib.astype_intsafe(arr, dtype)
  File "pandas/_libs/lib.pyx", line 668, in pandas._libs.lib.astype_intsafe
ValueError: invalid literal for int() with base 10: '--'

Cause

All entries in the minutes played column are '--', so the column can't be cast as an integer

dcstats commented 1 year ago

Fixed with 5fa8f60190a410077fa37cb347671e2877dce868