[GH-ISSUE #679] [Sofascore] Provided example with adding custom league doesn't work (Eredivisie) #141

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

Originally created by @comandante-zi on GitHub (Aug 15, 2024).
Original GitHub issue: https://github.com/probberechts/soccerdata/issues/679

I'm following guide to add custom league from sofifa and it doesn't work. (Python3.9 on WSL)

Here is my code

import pandas as pd
pd.set_option('display.max_columns', None)
import soccerdata as sd

#Create scraper class instance
sofascore = sd.Sofascore(leagues='NED-Eredivisie', seasons='2122', no_cache=True)

print(sd.Sofascore.available_leagues())

leagues = sofascore.read_leagues()
print(leagues.head())

schedule = sofascore.read_schedule(force_cache=False)
print(schedule.head())

Here's the error

[08/15/24 17:56:23] INFO     No custom team name replacements found. You can configure these in                              _config.py:90
                             /root/soccerdata/config/teamname_replacements.json.
                    INFO     Custom league dict loaded from /root/soccerdata/config/league_dict.json.                       _config.py:194
[08/15/24 17:56:24] INFO     Saving cached data to /root/soccerdata/data/Sofascore                                          _common.py:263
['ENG-Premier League', 'ESP-La Liga', 'FRA-Ligue 1', 'GER-Bundesliga', 'INT-European Championship', 'ITA-Serie A', 'NED-Eredivisie', 'QPL']
Traceback (most recent call last):
  File "/mnt/f/python/soccerdata_bot/soccerdata_bot.py", line 14, in <module>
    leagues = sofascore.read_leagues()
  File "/mnt/f/python/soccerdata_bot/python3.9_venv/lib/python3.9/site-packages/soccerdata/sofascore.py", line 102, in read_leagues
    pd.DataFrame(leagues)
  File "/mnt/f/python/soccerdata_bot/python3.9_venv/lib/python3.9/site-packages/pandas/core/indexing.py", line 1191, in __getitem__
    return self._getitem_axis(maybe_callable, axis=axis)
  File "/mnt/f/python/soccerdata_bot/python3.9_venv/lib/python3.9/site-packages/pandas/core/indexing.py", line 1420, in _getitem_axis
    return self._getitem_iterable(key, axis=axis)
  File "/mnt/f/python/soccerdata_bot/python3.9_venv/lib/python3.9/site-packages/pandas/core/indexing.py", line 1360, in _getitem_iterable
    keyarr, indexer = self._get_listlike_indexer(key, axis)
  File "/mnt/f/python/soccerdata_bot/python3.9_venv/lib/python3.9/site-packages/pandas/core/indexing.py", line 1558, in _get_listlike_indexer
    keyarr, indexer = ax._get_indexer_strict(key, axis_name)
  File "/mnt/f/python/soccerdata_bot/python3.9_venv/lib/python3.9/site-packages/pandas/core/indexes/base.py", line 6200, in _get_indexer_strict
    self._raise_if_missing(keyarr, indexer, axis_name)
  File "/mnt/f/python/soccerdata_bot/python3.9_venv/lib/python3.9/site-packages/pandas/core/indexes/base.py", line 6249, in _raise_if_missing
    raise KeyError(f"None of [{key}] are in the [{axis_name}]")
KeyError: "None of [Index(['NED-Eredivisie'], dtype='object', name='league')] are in the [index]"

Another non-top league doesn't work too. Also I found out, that there is URL which using /top-unique-tournament/ and it doesn't provide info about Eredivisie or Qazaqstan Premiere League (QPL above).

Is it even possible to add custom league from sofascored?

Originally created by @comandante-zi on GitHub (Aug 15, 2024). Original GitHub issue: https://github.com/probberechts/soccerdata/issues/679 I'm following guide to add custom league from sofifa and it doesn't work. (Python3.9 on WSL) Here is my code ``` import pandas as pd pd.set_option('display.max_columns', None) import soccerdata as sd #Create scraper class instance sofascore = sd.Sofascore(leagues='NED-Eredivisie', seasons='2122', no_cache=True) print(sd.Sofascore.available_leagues()) leagues = sofascore.read_leagues() print(leagues.head()) schedule = sofascore.read_schedule(force_cache=False) print(schedule.head()) ``` Here's the error ``` [08/15/24 17:56:23] INFO No custom team name replacements found. You can configure these in _config.py:90 /root/soccerdata/config/teamname_replacements.json. INFO Custom league dict loaded from /root/soccerdata/config/league_dict.json. _config.py:194 [08/15/24 17:56:24] INFO Saving cached data to /root/soccerdata/data/Sofascore _common.py:263 ['ENG-Premier League', 'ESP-La Liga', 'FRA-Ligue 1', 'GER-Bundesliga', 'INT-European Championship', 'ITA-Serie A', 'NED-Eredivisie', 'QPL'] Traceback (most recent call last): File "/mnt/f/python/soccerdata_bot/soccerdata_bot.py", line 14, in <module> leagues = sofascore.read_leagues() File "/mnt/f/python/soccerdata_bot/python3.9_venv/lib/python3.9/site-packages/soccerdata/sofascore.py", line 102, in read_leagues pd.DataFrame(leagues) File "/mnt/f/python/soccerdata_bot/python3.9_venv/lib/python3.9/site-packages/pandas/core/indexing.py", line 1191, in __getitem__ return self._getitem_axis(maybe_callable, axis=axis) File "/mnt/f/python/soccerdata_bot/python3.9_venv/lib/python3.9/site-packages/pandas/core/indexing.py", line 1420, in _getitem_axis return self._getitem_iterable(key, axis=axis) File "/mnt/f/python/soccerdata_bot/python3.9_venv/lib/python3.9/site-packages/pandas/core/indexing.py", line 1360, in _getitem_iterable keyarr, indexer = self._get_listlike_indexer(key, axis) File "/mnt/f/python/soccerdata_bot/python3.9_venv/lib/python3.9/site-packages/pandas/core/indexing.py", line 1558, in _get_listlike_indexer keyarr, indexer = ax._get_indexer_strict(key, axis_name) File "/mnt/f/python/soccerdata_bot/python3.9_venv/lib/python3.9/site-packages/pandas/core/indexes/base.py", line 6200, in _get_indexer_strict self._raise_if_missing(keyarr, indexer, axis_name) File "/mnt/f/python/soccerdata_bot/python3.9_venv/lib/python3.9/site-packages/pandas/core/indexes/base.py", line 6249, in _raise_if_missing raise KeyError(f"None of [{key}] are in the [{axis_name}]") KeyError: "None of [Index(['NED-Eredivisie'], dtype='object', name='league')] are in the [index]" ``` Another non-top league doesn't work too. Also I found out, that there is URL which using /top-unique-tournament/ and it doesn't provide info about Eredivisie or Qazaqstan Premiere League (QPL above). Is it even possible to add custom league from sofascored?
kerem 2026-03-02 15:56:08 +03:00
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#141
No description provided.