Closed dcstats closed 1 year ago
ms.get_game_pbp('400915255')
ValueError Traceback (most recent call last) Input In [24], in <cell line: 1>() ----> 1 s.get_game_pbp(400915255) File ~/Documents/Projects/CBBpy/testing/espn/mens/scrape.py:245, in get_game_pbp(game_id) 241 else: 242 # no exception thrown 243 break --> 245 return pd.concat(pbp_halves) File /opt/homebrew/Caskroom/miniforge/base/lib/python3.9/site-packages/pandas/util/_decorators.py:311, in deprecate_nonkeyword_arguments.<locals>.decorate.<locals>.wrapper(*args, **kwargs) 305 if len(args) > num_allow_args: 306 warnings.warn( 307 msg.format(arguments=arguments), 308 FutureWarning, 309 stacklevel=stacklevel, 310 ) --> 311 return func(*args, **kwargs) File /opt/homebrew/Caskroom/miniforge/base/lib/python3.9/site-packages/pandas/core/reshape/concat.py:347, in concat(objs, axis, join, ignore_index, keys, levels, names, verify_integrity, sort, copy) 143 @deprecate_nonkeyword_arguments(version=None, allowed_args=["objs"]) 144 def concat( 145 objs: Iterable[NDFrame] | Mapping[Hashable, NDFrame], (...) 154 copy: bool = True, 155 ) -> DataFrame | Series: 156 """ 157 Concatenate pandas objects along a particular axis with optional set logic 158 along the other axes. (...) 345 ValueError: Indexes have overlapping values: ['a'] 346 """ --> 347 op = _Concatenator( 348 objs, 349 axis=axis, 350 ignore_index=ignore_index, 351 join=join, 352 keys=keys, 353 levels=levels, 354 names=names, 355 verify_integrity=verify_integrity, 356 copy=copy, 357 sort=sort, 358 ) 360 return op.get_result() File /opt/homebrew/Caskroom/miniforge/base/lib/python3.9/site-packages/pandas/core/reshape/concat.py:404, in _Concatenator.__init__(self, objs, axis, join, keys, levels, names, ignore_index, verify_integrity, copy, sort) 401 objs = list(objs) 403 if len(objs) == 0: --> 404 raise ValueError("No objects to concatenate") 406 if keys is None: 407 objs = list(com.not_none(*objs)) ValueError: No objects to concatenate
KeyError('src') is thrown in _clean_pbp_table line 751-2: links = [row.find("img")["src"] if row.find("img") else None for row in body_rows]
_clean_pbp_table
links = [row.find("img")["src"] if row.find("img") else None for row in body_rows]
Also unexpected behavior - for PBPs with video replays, an extra column ('unnamed: 4') is being added
Fixed with d8d316ccfaaf7d9f6bbfda7a31b501b4888e14f1 and c8ca8369beee5ea6c10d518b70cfdc8ff0c1c920
Code
ms.get_game_pbp('400915255')
Traceback
Cause
KeyError('src') is thrown in
_clean_pbp_table
line 751-2:links = [row.find("img")["src"] if row.find("img") else None for row in body_rows]