Skip to content

Commit

Permalink
feat: add support for European Championship
Browse files Browse the repository at this point in the history
  • Loading branch information
probberechts committed Jun 16, 2024
1 parent 1da000f commit beb8f5b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
9 changes: 9 additions & 0 deletions soccerdata/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,15 @@
"WhoScored": "International - FIFA World Cup",
"season_code": "single-year",
},
"INT-European Championship": {
"FBref": "UEFA European Football Championship",
"FotMob": "INT-EURO",
"Sofascore": "EURO",
"WhoScored": "International - European Championship",
"season_start": "Jun",
"season_end": "Jul",
"season_code": "single-year",
},
"INT-Women's World Cup": {
"FBref": "FIFA Women's World Cup",
"FotMob": "INT-Women's World Cup",
Expand Down
20 changes: 15 additions & 5 deletions soccerdata/fbref.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,10 +441,14 @@ def read_team_match_stats( # noqa: C901
+ f"/{stat_type}"
)
else: # special case: latest season
season_format = "{}-{}".format(
datetime.strptime(skey[:2], "%y").year, # noqa: DTZ007
datetime.strptime(skey[2:], "%y").year, # noqa: DTZ007
)
if SeasonCode.from_league(lkey) == SeasonCode.MULTI_YEAR:
_skey = SeasonCode.MULTI_YEAR.parse(skey)
season_format = "{}-{}".format(
datetime.strptime(_skey[:2], "%y").year, # noqa: DTZ007
datetime.strptime(_skey[2:], "%y").year, # noqa: DTZ007
)
else:
season_format = SeasonCode.SINGLE_YEAR.parse(skey)
url = (
FBREF_API
+ team_url.rsplit("/", 1)[0]
Expand Down Expand Up @@ -522,7 +526,13 @@ def read_team_match_stats( # noqa: C901
lambda x: x["team"] if x["venue"] == "Away" else x["opponent"], axis=1
)
df["game"] = df_tmp.apply(make_game_id, axis=1)
return df.set_index(["league", "season", "team", "game"]).sort_index().loc[self.leagues]
return (
df
# .dropna(subset="league")
.set_index(["league", "season", "team", "game"])
.sort_index()
.loc[self.leagues]
)

def read_player_season_stats(self, stat_type: str = "standard") -> pd.DataFrame:
"""Retrieve players from the datasource for the selected leagues and seasons.
Expand Down

0 comments on commit beb8f5b

Please sign in to comment.