probberechts / soccerdata

⛏⚽ Scrape soccer data from Club Elo, ESPN, FBref, FiveThirtyEight, Football-Data.co.uk, FotMob, Sofascore, SoFIFA, Understat and WhoScored.
https://soccerdata.readthedocs.io/en/latest/
Other
607 stars 104 forks source link

[FBref] Summary stats shows error when concatenating different matches #292

Closed danielbaltruschat closed 1 year ago

danielbaltruschat commented 1 year ago

The fbref class is set to read from the English Premier league for the 17-18 season.

Error:

get all schedule copy.py 41 <module>
match_summary_stats = fbref.read_player_match_stats(stat_type="summary")

fbref.py 804 read_player_match_stats
df = _concat(stats)

fbref.py 1103 _concat
df.columns = pd.MultiIndex.from_tuples(columns.to_records(index=False).tolist())

generic.py 5915 __setattr__
return object.__setattr__(self, name, value)

properties.pyx 69 pandas._libs.properties.AxisProperty.__set__

generic.py 823 _set_axis
self._mgr.set_axis(axis, labels)

managers.py 230 set_axis
self._validate_set_axis(axis, new_labels)

base.py 70 _validate_set_axis
raise ValueError(

ValueError:
Length mismatch: Expected axis has 28 elements, new values have 36 elements
lorenzodb1 commented 1 year ago

284 should fix this issue

probberechts commented 1 year ago

This seems to work fine. Make sure you have the latest version installed and disable caching (likely, you are mixing old cached data with newly retrieved data). I ran the code below.

import soccerdata as sd
fbref = sd.FBref("ENG-Premier League", "1718", no_cache=True)
match_summary_stats = fbref.read_player_match_stats(stat_type="summary", no_cache=True)