[GH-ISSUE #482] [ESPN] Player Infos not retrievable #87

Closed
opened 2026-03-02 15:55:40 +03:00 by kerem · 0 comments
Owner

Originally created by @JJOSHTECH on GitHub (Feb 12, 2024).
Original GitHub issue: https://github.com/probberechts/soccerdata/issues/482

I encounter an error in ESPN.py (Python Version: 3.11.7; OS: Windows: 11; soccerdata: 1.5.3):

<path>\.venv\Lib\site-packages\soccerdata\fbref.py:674: FutureWarning: The behavior of DataFrame concatenation with empty or all-NA entries is deprecated. In a future version, this will no longer exclude empty or all-NA columns when determining the result dtypes. To retain the old behavior, exclude the relevant entries before the concat operation.
  pd.concat(schedule)
[02/12/24 18:48:52] INFO     No lineup info found for team 1 in game with ID=671269                                                                             espn.py:262
                    INFO     No lineup info found for team 2 in game with ID=671269                                                                             espn.py:262
Traceback (most recent call last):
  File "<path>main.py", line 258, in <module>
    main()
  File "<path>main.py", line 84, in main
    lineups = espn.read_lineup(match_id=copy.values)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<path>.venv\Lib\site-packages\soccerdata\espn.py", line 300, in read_lineup
    ii = [i for i, x in enumerate(p["plays"]) if x["substitution"]][j]
                                  ~^^^^^^^^^
KeyError: 'plays'

I am retrieving all the lineups and in match. The issue occurs in match 643973. The Problem is the Structur of one players Data that looks as follows:

{'active': True, 'starter': True, 'jersey': '13', 'athlete': {'id': '175149', 'uid': 's:600~a:175149', 'guid': 'ec62cfce-f0d0-3a90-7e94-7a2ba13a1336', 'lastName': 'Bounou', 'fullName': 'Yassine Bounou', 'displayName': 'Yassine Bounou', 'links': [{'language': 'en-US', 'rel': ['playercard', 'desktop', 'athlete'], 'href': 'http://www.espn.com/soccer/player/_/id/175149/yassine-bounou', 'text': 'Player Card', 'shortText': 'Player Card', 'isExternal': False, 'isPremium': False}], 'jersey': '13', 'position': {'$ref': 'http://sports.core.api.espn.pvt/v2/sports/soccer/leagues/esp.1/positions/1?lang=en&region=us', 'id': '1', 'name': 'Goalkeeper', 'displayName': 'Goalkeeper', 'abbreviation': 'G', 'leaf': True}}, 'position': {'id': '1', 'name': 'Goalkeeper', 'displayName': 'Goalkeeper', 'abbreviation': 'G'}, 'subbedIn': {'didSub': False}, 'subbedOut': {'didSub': False}, 'formationPlace': '1'}

Especially this Part is odd: 'subbedOut': {'didSub': False} in other Playersdata this is directly a boolean and there are no sub fields. My solution is now to change ESPN.py at line 298 as follows: elif p["subbedOut"] and isinstance(p["subbedOut"], bool):

I recognized the same error for subbedIn as well. So i changed line 282 as well: elif p["subbedIn"] and isinstance(p["subbedIn"], bool):

Does someone has a better solution?

Originally created by @JJOSHTECH on GitHub (Feb 12, 2024). Original GitHub issue: https://github.com/probberechts/soccerdata/issues/482 I encounter an error in ESPN.py (Python Version: 3.11.7; OS: Windows: 11; soccerdata: 1.5.3): ``` <path>\.venv\Lib\site-packages\soccerdata\fbref.py:674: FutureWarning: The behavior of DataFrame concatenation with empty or all-NA entries is deprecated. In a future version, this will no longer exclude empty or all-NA columns when determining the result dtypes. To retain the old behavior, exclude the relevant entries before the concat operation. pd.concat(schedule) [02/12/24 18:48:52] INFO No lineup info found for team 1 in game with ID=671269 espn.py:262 INFO No lineup info found for team 2 in game with ID=671269 espn.py:262 Traceback (most recent call last): File "<path>main.py", line 258, in <module> main() File "<path>main.py", line 84, in main lineups = espn.read_lineup(match_id=copy.values) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "<path>.venv\Lib\site-packages\soccerdata\espn.py", line 300, in read_lineup ii = [i for i, x in enumerate(p["plays"]) if x["substitution"]][j] ~^^^^^^^^^ KeyError: 'plays' ``` I am retrieving all the lineups and in match. The issue occurs in match 643973. The Problem is the Structur of one players Data that looks as follows: ``` {'active': True, 'starter': True, 'jersey': '13', 'athlete': {'id': '175149', 'uid': 's:600~a:175149', 'guid': 'ec62cfce-f0d0-3a90-7e94-7a2ba13a1336', 'lastName': 'Bounou', 'fullName': 'Yassine Bounou', 'displayName': 'Yassine Bounou', 'links': [{'language': 'en-US', 'rel': ['playercard', 'desktop', 'athlete'], 'href': 'http://www.espn.com/soccer/player/_/id/175149/yassine-bounou', 'text': 'Player Card', 'shortText': 'Player Card', 'isExternal': False, 'isPremium': False}], 'jersey': '13', 'position': {'$ref': 'http://sports.core.api.espn.pvt/v2/sports/soccer/leagues/esp.1/positions/1?lang=en&region=us', 'id': '1', 'name': 'Goalkeeper', 'displayName': 'Goalkeeper', 'abbreviation': 'G', 'leaf': True}}, 'position': {'id': '1', 'name': 'Goalkeeper', 'displayName': 'Goalkeeper', 'abbreviation': 'G'}, 'subbedIn': {'didSub': False}, 'subbedOut': {'didSub': False}, 'formationPlace': '1'} ``` Especially this Part is odd: `'subbedOut': {'didSub': False}` in other Playersdata this is directly a boolean and there are no sub fields. My solution is now to change ESPN.py at line 298 as follows: `elif p["subbedOut"] and isinstance(p["subbedOut"], bool):` I recognized the same error for subbedIn as well. So i changed line 282 as well: `elif p["subbedIn"] and isinstance(p["subbedIn"], bool):` Does someone has a better solution?
kerem 2026-03-02 15:55:40 +03:00
  • closed this issue
  • added the
    bug
    ESPN
    labels
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/soccerdata#87
No description provided.