[GH-ISSUE #790] [WhoScored] La Liga issue #167

Closed
opened 2026-03-02 15:56:20 +03:00 by kerem · 2 comments
Owner

Originally created by @Messe57 on GitHub (Jan 17, 2025).
Original GitHub issue: https://github.com/probberechts/soccerdata/issues/790

I use to download data for top 5 leagues, but lately La Liga stop working due to an unknown issue. I tried to define what was, but I couldn't. I use a VPN when I scrape because my local language cause some problems. Thanks in advance for your help.

import soccerdata as sd
seasons = ['2425'] 
leagues = ['ESP-La Liga']  

for season in seasons:
    for league in leagues:
        ws = sd.WhoScored(leagues=league, seasons=season, headless=False) 
        ws._driver.get("https://www.whoscored.com/")
        ws._driver.execute_script("location = 'https://whoscored.com/'")
        schedule = ws.read_schedule()
        matches = ws.read_events(output_fmt='events')

This is the error I get:

KeyError                                  Traceback (most recent call last)
Cell In[17], [line 14](vscode-notebook-cell:?execution_count=17&line=14)
     [12](vscode-notebook-cell:?execution_count=17&line=12) ws._driver.get("https://www.whoscored.com/")
     [13](vscode-notebook-cell:?execution_count=17&line=13) ws._driver.execute_script("location = 'https://whoscored.com/'")
---> [14](vscode-notebook-cell:?execution_count=17&line=14) schedule = ws.read_schedule()
     [15](vscode-notebook-cell:?execution_count=17&line=15) matches = ws.read_events(output_fmt='events') 

File c:\Users\filip\AppData\Local\Programs\Python\Python311\Lib\site-packages\soccerdata\whoscored.py:347, in WhoScored.read_schedule(self, force_cache)
    [334](file:///C:/Users/filip/AppData/Local/Programs/Python/Python311/Lib/site-packages/soccerdata/whoscored.py:334) def read_schedule(self, force_cache: bool = False) -> pd.DataFrame:
    [335](file:///C:/Users/filip/AppData/Local/Programs/Python/Python311/Lib/site-packages/soccerdata/whoscored.py:335)     """Retrieve the game schedule for the selected leagues and seasons.
    [336](file:///C:/Users/filip/AppData/Local/Programs/Python/Python311/Lib/site-packages/soccerdata/whoscored.py:336) 
    [337](file:///C:/Users/filip/AppData/Local/Programs/Python/Python311/Lib/site-packages/soccerdata/whoscored.py:337)     Parameters
   (...)
    [345](file:///C:/Users/filip/AppData/Local/Programs/Python/Python311/Lib/site-packages/soccerdata/whoscored.py:345)     pd.DataFrame
    [346](file:///C:/Users/filip/AppData/Local/Programs/Python/Python311/Lib/site-packages/soccerdata/whoscored.py:346)     """
--> [347](file:///C:/Users/filip/AppData/Local/Programs/Python/Python311/Lib/site-packages/soccerdata/whoscored.py:347)     df_season_stages = self.read_season_stages(force_cache=force_cache)
    [348](file:///C:/Users/filip/AppData/Local/Programs/Python/Python311/Lib/site-packages/soccerdata/whoscored.py:348)     filemask_schedule = "matches/{}_{}_{}_{}.json"
    [350](file:///C:/Users/filip/AppData/Local/Programs/Python/Python311/Lib/site-packages/soccerdata/whoscored.py:350)     all_schedules = []

File c:\Users\filip\AppData\Local\Programs\Python\Python311\Lib\site-packages\soccerdata\whoscored.py:277, in WhoScored.read_season_stages(self, force_cache)
    [264](file:///C:/Users/filip/AppData/Local/Programs/Python/Python311/Lib/site-packages/soccerdata/whoscored.py:264) def read_season_stages(self, force_cache: bool = False) -> pd.DataFrame:
    [265](file:///C:/Users/filip/AppData/Local/Programs/Python/Python311/Lib/site-packages/soccerdata/whoscored.py:265)     """Retrieve the season stages for the selected leagues.
    [266](file:///C:/Users/filip/AppData/Local/Programs/Python/Python311/Lib/site-packages/soccerdata/whoscored.py:266) 
    [267](file:///C:/Users/filip/AppData/Local/Programs/Python/Python311/Lib/site-packages/soccerdata/whoscored.py:267)     Parameters
...
-> [6249](file:///C:/Users/filip/AppData/Local/Programs/Python/Python311/Lib/site-packages/pandas/core/indexes/base.py:6249)         raise KeyError(f"None of [{key}] are in the [{axis_name}]")
   [6251](file:///C:/Users/filip/AppData/Local/Programs/Python/Python311/Lib/site-packages/pandas/core/indexes/base.py:6251)     not_found = list(ensure_index(key)[missing_mask.nonzero()[0]].unique())
   [6252](file:///C:/Users/filip/AppData/Local/Programs/Python/Python311/Lib/site-packages/pandas/core/indexes/base.py:6252)     raise KeyError(f"{not_found} not in index")

KeyError: "None of [Index(['ESP-La Liga'], dtype='object', name='league')] are in the [index]
Originally created by @Messe57 on GitHub (Jan 17, 2025). Original GitHub issue: https://github.com/probberechts/soccerdata/issues/790 I use to download data for top 5 leagues, but lately La Liga stop working due to an unknown issue. I tried to define what was, but I couldn't. I use a VPN when I scrape because my local language cause some problems. Thanks in advance for your help. ``` import soccerdata as sd seasons = ['2425'] leagues = ['ESP-La Liga'] for season in seasons: for league in leagues: ws = sd.WhoScored(leagues=league, seasons=season, headless=False) ws._driver.get("https://www.whoscored.com/") ws._driver.execute_script("location = 'https://whoscored.com/'") schedule = ws.read_schedule() matches = ws.read_events(output_fmt='events') ``` This is the error I get: ``` KeyError Traceback (most recent call last) Cell In[17], [line 14](vscode-notebook-cell:?execution_count=17&line=14) [12](vscode-notebook-cell:?execution_count=17&line=12) ws._driver.get("https://www.whoscored.com/") [13](vscode-notebook-cell:?execution_count=17&line=13) ws._driver.execute_script("location = 'https://whoscored.com/'") ---> [14](vscode-notebook-cell:?execution_count=17&line=14) schedule = ws.read_schedule() [15](vscode-notebook-cell:?execution_count=17&line=15) matches = ws.read_events(output_fmt='events') File c:\Users\filip\AppData\Local\Programs\Python\Python311\Lib\site-packages\soccerdata\whoscored.py:347, in WhoScored.read_schedule(self, force_cache) [334](file:///C:/Users/filip/AppData/Local/Programs/Python/Python311/Lib/site-packages/soccerdata/whoscored.py:334) def read_schedule(self, force_cache: bool = False) -> pd.DataFrame: [335](file:///C:/Users/filip/AppData/Local/Programs/Python/Python311/Lib/site-packages/soccerdata/whoscored.py:335) """Retrieve the game schedule for the selected leagues and seasons. [336](file:///C:/Users/filip/AppData/Local/Programs/Python/Python311/Lib/site-packages/soccerdata/whoscored.py:336) [337](file:///C:/Users/filip/AppData/Local/Programs/Python/Python311/Lib/site-packages/soccerdata/whoscored.py:337) Parameters (...) [345](file:///C:/Users/filip/AppData/Local/Programs/Python/Python311/Lib/site-packages/soccerdata/whoscored.py:345) pd.DataFrame [346](file:///C:/Users/filip/AppData/Local/Programs/Python/Python311/Lib/site-packages/soccerdata/whoscored.py:346) """ --> [347](file:///C:/Users/filip/AppData/Local/Programs/Python/Python311/Lib/site-packages/soccerdata/whoscored.py:347) df_season_stages = self.read_season_stages(force_cache=force_cache) [348](file:///C:/Users/filip/AppData/Local/Programs/Python/Python311/Lib/site-packages/soccerdata/whoscored.py:348) filemask_schedule = "matches/{}_{}_{}_{}.json" [350](file:///C:/Users/filip/AppData/Local/Programs/Python/Python311/Lib/site-packages/soccerdata/whoscored.py:350) all_schedules = [] File c:\Users\filip\AppData\Local\Programs\Python\Python311\Lib\site-packages\soccerdata\whoscored.py:277, in WhoScored.read_season_stages(self, force_cache) [264](file:///C:/Users/filip/AppData/Local/Programs/Python/Python311/Lib/site-packages/soccerdata/whoscored.py:264) def read_season_stages(self, force_cache: bool = False) -> pd.DataFrame: [265](file:///C:/Users/filip/AppData/Local/Programs/Python/Python311/Lib/site-packages/soccerdata/whoscored.py:265) """Retrieve the season stages for the selected leagues. [266](file:///C:/Users/filip/AppData/Local/Programs/Python/Python311/Lib/site-packages/soccerdata/whoscored.py:266) [267](file:///C:/Users/filip/AppData/Local/Programs/Python/Python311/Lib/site-packages/soccerdata/whoscored.py:267) Parameters ... -> [6249](file:///C:/Users/filip/AppData/Local/Programs/Python/Python311/Lib/site-packages/pandas/core/indexes/base.py:6249) raise KeyError(f"None of [{key}] are in the [{axis_name}]") [6251](file:///C:/Users/filip/AppData/Local/Programs/Python/Python311/Lib/site-packages/pandas/core/indexes/base.py:6251) not_found = list(ensure_index(key)[missing_mask.nonzero()[0]].unique()) [6252](file:///C:/Users/filip/AppData/Local/Programs/Python/Python311/Lib/site-packages/pandas/core/indexes/base.py:6252) raise KeyError(f"{not_found} not in index") KeyError: "None of [Index(['ESP-La Liga'], dtype='object', name='league')] are in the [index] ```
kerem 2026-03-02 15:56:20 +03:00
  • closed this issue
  • added the
    WhoScored
    label
Author
Owner

@probberechts commented on GitHub (Jan 21, 2025):

Can you check the following:

1, Have you updated to the newest version of soccerdata?

>>> import soccerdata as sd
>>> print(sd.__version__)
1.8.5
  1. Clear the cache or run your script without caching enabled.
>>> import soccerdata as sd
>>> ws = sd.WhoScored(leagues='ESP-La Liga', seasons='2425', no_cache=True)
>>> ws.read_schedule()
<!-- gh-comment-id:2605173382 --> @probberechts commented on GitHub (Jan 21, 2025): Can you check the following: 1, Have you updated to the newest version of soccerdata? ```py >>> import soccerdata as sd >>> print(sd.__version__) 1.8.5 ``` 2. Clear the cache or run your script without caching enabled. ```py >>> import soccerdata as sd >>> ws = sd.WhoScored(leagues='ESP-La Liga', seasons='2425', no_cache=True) >>> ws.read_schedule() ```
Author
Owner

@Messe57 commented on GitHub (Jan 21, 2025):

Thank you very much, after cleaning the cache, it's working perfectly again.

<!-- gh-comment-id:2605196357 --> @Messe57 commented on GitHub (Jan 21, 2025): Thank you very much, after cleaning the cache, it's working perfectly again.
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#167
No description provided.