Skip to main content

Soccer (all) — additional Python functions

Hand-written wrappers, loaders, and helpers in sportsdataverse.soccer that are not generated API-endpoint wrappers (those have their own reference pages).

kloppy open event data​

NotFittedError​

NotFittedError(...)

The grid is all zeros: call fit or load a model first.

XThreat​

XThreat(grid: 'Optional[np.ndarray]' = None, *, l: 'int' = 16, w: 'int' = 12, eps: 'float' = 1e-05, max_iter: 'int' = 1000, meta: 'Optional[dict[str, Any]]' = None) -> 'None'

A fitted Expected Threat grid.

Parameters

ParameterTypeDefaultDescription
gridOptional[ndarray]NoneAn existing (w, l) array (row 0 = the top of the pitch); None for an unfitted model.
lint16Cells along the pitch length.
wint12Cells across the pitch width.
epsfloat1e-05Convergence tolerance on the absolute change of every cell.
max_iterint1000Iteration cap; exceeding it raises RuntimeError.
metaOptional[dict[str, Any]]NoneFree-form provenance stored in the JSON.

Example

from sportsdataverse.soccer import XThreat, soccer_open_dataset, soccer_spadl
actions = soccer_spadl(soccer_open_dataset("statsbomb", 8658))
model = XThreat().fit(actions)
actions = actions.with_columns(model.rate(actions))

Methods

XThreat.fit​

XThreat.fit(actions: 'pl.DataFrame') -> 'XThreat'

Fit the grid on SPADL actions by value iteration.

Parameters

ParameterTypeDefaultDescription
actionsDataFrameSPADL actions with type_name, result_name and start/end coordinates.

Returns

This model, fitted in place.

Raises

ExceptionDescription
RuntimeErrorIf the grid has not converged within max_iter iterations.

Example

from sportsdataverse.soccer import XThreat, soccer_open_dataset, soccer_spadl
model = XThreat().fit(soccer_spadl(soccer_open_dataset("statsbomb", 8658)))
print(model.iterations)

XThreat.from_json​

XThreat.from_json(path: 'Union[str, Path]') -> 'XThreat'

Read this module's format or socceraction's bare nested list.

Parameters

ParameterTypeDefaultDescription
pathUnion[str, Path]A JSON file written by to_json or socceraction's save_model.

Returns

The loaded XThreat.

Example

from sportsdataverse.soccer import XThreat
model = XThreat.from_json("xthreat.json")

XThreat.rate​

XThreat.rate(actions: 'pl.DataFrame') -> 'pl.Series'

Rate each action: end-cell minus start-cell value for successful passes, dribbles and crosses.

Parameters

ParameterTypeDefaultDescription
actionsDataFrameSPADL actions with type_name, result_name and start/end coordinates.

Returns

A Float64 series named xt_value; null for actions xT does not value.

Raises

ExceptionDescription
NotFittedErrorIf the grid is all zeros.

Example

from sportsdataverse.soccer import load_xthreat_model
actions = actions.with_columns(load_xthreat_model().rate(actions))

XThreat.to_json​

XThreat.to_json(path: 'Union[str, Path]') -> 'None'

Write {"xT": grid, "w": .., "l": .., "meta": {..}} (readable by from_json).

Parameters

ParameterTypeDefaultDescription
pathUnion[str, Path]Destination file.

Example

model.to_json("xthreat.json")

load_xthreat_model​

load_xthreat_model() -> 'XThreat'

The bundled grid fit on StatsBomb open data (see meta for competitions, counts and license).

Returns

The fitted XThreat shipped with the package.

Example

from sportsdataverse.soccer import load_xthreat_model
model = load_xthreat_model()
print(model.xT.shape, model.meta["matches"])

soccer_events_to_frame​

soccer_events_to_frame(dataset: 'Any', *, return_as_pandas: 'bool' = False) -> 'Union[pl.DataFrame, pd.DataFrame]'

Turn a kloppy dataset (any provider, any file) into a tidy frame.

The one place the package's column convention is applied to kloppy output: one row per event, columns snake-cased (kloppy's own names -- event_id, event_type, period_id, timestamp, team_id, player_id, coordinates_x, coordinates_y, ... -- already are, so this is a no-op guard for any extra column).

Parameters

ParameterTypeDefaultDescription
datasetAnyA kloppy EventDataset (or any dataset with to_df), e.g. from kloppy.statsbomb.load(event_data=..., lineup_data=...) or kloppy.opta.load(...).
return_as_pandasboolFalseReturn a pandas DataFrame instead of polars.

Returns

A polars DataFrame (pandas with return_as_pandas=True), one row per event. Coordinates are in the dataset's coordinate system -- kloppy's default is a 0-1 normalized pitch; pass coordinates="statsbomb" (etc.) to kloppy's loader to keep the provider's units.

col_nametypedescription
event_idString
event_typeString
period_idInt64
timestampString
end_timestampString
ball_stateString
ball_owning_teamString
team_idString
player_idString
coordinates_xFloat64
coordinates_yFloat64
resultString
successBoolean
end_coordinates_xFloat64
end_coordinates_yFloat64
receiver_player_idString
set_piece_typeString
body_part_typeString
is_under_pressureBoolean
pass_typeString
duel_typeString
goalkeeper_typeString
is_counter_attackBoolean
card_typeString

Raises

ExceptionDescription
AttributeErrordataset has no to_df (it is not a kloppy dataset).

Example

from kloppy import statsbomb
from sportsdataverse.soccer import soccer_events_to_frame
ds = statsbomb.load(event_data="8658.json", lineup_data="lineups_8658.json")
df = soccer_events_to_frame(ds)
print(df.shape)

# Useful parameter combination

df_pd = soccer_events_to_frame(ds, return_as_pandas=True)

# Pipeline next step (one line)

df.filter(pl.col("event_type") == "SHOT").select("player_id", "coordinates_x", "coordinates_y")

soccer_open_dataset​

soccer_open_dataset(provider: 'str', match_id: 'Union[int, str]', **kwargs: 'Any') -> 'Any'

Load one match of a provider's free open event data as a kloppy EventDataset.

provider="statsbomb" reads StatsBomb open data (https://github.com/statsbomb/open-data) through kloppy.statsbomb.load_open_data(match_id=...). That data is free for research and non-commercial use only, under StatsBomb's open-data license -- read it before publishing anything built on it. This is the input soccer_spadl expects; soccer_open_events is the same load flattened to a frame.

Parameters

ParameterTypeDefaultDescription
providerstrOpen-data provider key; currently "statsbomb".
match_idUnion[int, str]The provider's match id (StatsBomb: e.g. 8658 -- France v Croatia, 2018 World Cup final).

Returns

A kloppy EventDataset.

Raises

ExceptionDescription
ImportErrorKloppy is not installed -- pip install "sportsdataverse[soccer]".
ValueErrorprovider is not a supported open-data key.
AssetFetchErrorThe events file arrived truncated or corrupt twice (the retry evicts kloppy's cached copy first).

Example

from sportsdataverse.soccer import soccer_open_dataset, soccer_spadl
dataset = soccer_open_dataset("statsbomb", 8658)
actions = soccer_spadl(dataset)

# Pipeline next step (one line)

frame = dataset.to_df(engine="polars")

soccer_open_events​

soccer_open_events(provider: 'str', match_id: 'Union[int, str]', *, return_as_pandas: 'bool' = False, **kwargs: 'Any') -> 'Union[pl.DataFrame, pd.DataFrame]'

Load one match of a provider's free open event data as a tidy frame.

provider="statsbomb" reads StatsBomb open data (https://github.com/statsbomb/open-data) through kloppy.statsbomb.load_open_data(match_id=...). That data is free for research and non-commercial use only, under StatsBomb's open-data license -- read it before publishing anything built on it. Other kloppy open samples (Metrica, SkillCorner) follow the same shape and are added on request.

Parameters

ParameterTypeDefaultDescription
providerstrOpen-data provider key; currently "statsbomb".
match_idUnion[int, str]The provider's match id (StatsBomb: e.g. 8658 -- France v Croatia, 2018 World Cup final).
return_as_pandasboolFalseReturn a pandas DataFrame instead of polars.

Returns

A polars DataFrame (pandas with return_as_pandas=True), one row per event; see soccer_events_to_frame for the columns.

col_nametypedescription
event_idString
event_typeString
period_idInt64
timestampString
end_timestampString
ball_stateString
ball_owning_teamString
team_idString
player_idString
coordinates_xFloat64
coordinates_yFloat64
resultString
successBoolean
end_coordinates_xFloat64
end_coordinates_yFloat64
receiver_player_idString
set_piece_typeString
body_part_typeString
is_under_pressureBoolean
pass_typeString
duel_typeString
goalkeeper_typeString
is_counter_attackBoolean
card_typeString

Raises

ExceptionDescription
ImportErrorKloppy is not installed -- pip install "sportsdataverse[soccer]".
ValueErrorprovider is not a supported open-data key.
AssetFetchErrorThe events file arrived truncated or corrupt twice (the retry evicts kloppy's cached copy first).

Example

from sportsdataverse.soccer import soccer_open_events
df = soccer_open_events("statsbomb", 8658)
print(df.shape)

# Useful parameter combination

df_pd = soccer_open_events("statsbomb", 8658, coordinates="statsbomb", return_as_pandas=True)

# Pipeline next step (one line)

df.filter(pl.col("event_type") == "SHOT").group_by("team_id").len()

soccer_spadl​

soccer_spadl(dataset: 'Any', *, game_id: 'Optional[Union[int, str]]' = None, return_as_pandas: 'bool' = False) -> "Union[pl.DataFrame, 'pd.DataFrame']"

Convert a kloppy event dataset to SPADL actions on the 105 x 68 pitch.

Every action attacks left to right (kloppy ACTION_EXECUTING_TEAM orientation), so a frame from any provider kloppy reads is comparable. StatsBomb is the tested path.

Parameters

ParameterTypeDefaultDescription
datasetAnyA kloppy EventDataset (e.g. from soccer_open_dataset).
game_idOptional[Union[int, str]]NoneGame identifier when the dataset's metadata carries none.
return_as_pandasboolFalseReturn a pandas DataFrame instead of polars.

Returns

One row per on-ball action with the SPADL columns (type_name, result_name, bodypart_name, start/end coordinates in meters, time_seconds from the period's kick-off). Empty dataset -> zero-row frame with the same schema.

col_nametypedescription
game_idString
original_event_idString
action_idInt64
period_idInt64
time_secondsFloat64
team_idString
player_idString
start_xFloat64
start_yFloat64
end_xFloat64
end_yFloat64
bodypart_idInt64
bodypart_nameString
type_idInt64
type_nameString
result_idInt64
result_nameString

Raises

ExceptionDescription
ImportErrorKloppy is missing (pip install "sportsdataverse[soccer]").
ValueErrorNeither the dataset nor game_id names the game; or the dataset's provider has no usable coordinate system (unknown / OTHER) or its pitch dimensions are not fixed.

Example

from sportsdataverse.soccer import soccer_open_dataset, soccer_spadl
actions = soccer_spadl(soccer_open_dataset("statsbomb", 8658))
print(actions.shape)

# Pipeline next step (one line)

actions.filter(pl.col("type_name") == "shot").group_by("team_id").len()

soccer_xthreat_rate​

soccer_xthreat_rate(actions: 'pl.DataFrame', model: 'Optional[XThreat]' = None, *, return_as_pandas: 'bool' = False) -> 'Union[pl.DataFrame, pd.DataFrame]'

Append xt_value (Expected Threat added by each successful pass, dribble or cross) to a SPADL frame.

Parameters

ParameterTypeDefaultDescription
actionsDataFrameSPADL actions from soccer_spadl (needs type_name, result_name, start/end coordinates).
modelOptional[XThreat]NoneA fitted XThreat; None uses the bundled grid.
return_as_pandasboolFalseReturn a pandas DataFrame instead of polars.

Returns

actions with a Float64 xt_value column (null for actions xT does not value).

col_nametypedescription
game_idString
original_event_idString
action_idInt64
period_idInt64
time_secondsFloat64
team_idString
player_idString
start_xFloat64
start_yFloat64
end_xFloat64
end_yFloat64
bodypart_idInt64
bodypart_nameString
type_idInt64
type_nameString
result_idInt64
result_nameString
xt_valueFloat64

Raises

ExceptionDescription
NotFittedErrorIf model is an unfitted grid.

Example

import polars as pl
from sportsdataverse.soccer import soccer_open_dataset, soccer_spadl, soccer_xthreat_rate
actions = soccer_xthreat_rate(soccer_spadl(soccer_open_dataset("statsbomb", 8658)))
print(actions.group_by("player_id").agg(pl.col("xt_value").sum()).sort("xt_value", descending=True).head())

reep football id register​

soccer_espn_reep_team_crosswalk​

soccer_espn_reep_team_crosswalk(league: 'str | None' = None, *, return_as_pandas: 'bool' = False) -> 'pl.DataFrame | pd.DataFrame'

ESPN soccer team id -> reep team id, with reep's ids for the same club at about 20 providers.

One row per ESPN team in the leagues the table covers: eng.1, eng.2, esp.1, ger.1, ita.1, fra.1, usa.1 and mex.1 (the clubs ESPN listed when the table was built, 2026-11-26). The table ships with sdv-py; no request is made. reep data is CC0 1.0 (release 2026.25). NWSL is not covered: reep has no row for 5 of its 16 clubs, below the 75% per-league floor.

Parameters

ParameterTypeDefaultDescription
leaguestr | NoneNoneAn ESPN league slug from the list above, to keep that league's rows; None (default) returns every league.
return_as_pandasboolFalseReturn a pandas DataFrame instead of polars.

Returns

polars.DataFrame | pandas.DataFrame: one row per espn_team_id (unique). Every column is text (Utf8): espn_team_id joins espn_soccer_teams_site().team_id and the ESPN soccer scoreboard and summary team ids as it is. The reep columns are null when no reep row is that club (match_method == "unmatched").

col_nametypedescription
espn_team_idStringESPN soccer team id, digits as text (Utf8, the dtype of team_id in espn_soccer_teams_site and the ESPN soccer scoreboard and summary frames); unique in the table.
espn_leagueStringESPN league slug the team was listed under when the table was built (eng.1, eng.2, esp.1, ger.1, ita.1, fra.1, usa.1, mex.1).
espn_display_nameStringESPN display name of the team at build time (e.g. 'Manchester United').
espn_abbreviationStringESPN team abbreviation at build time (e.g. 'MAN' for Manchester United).
reep_idStringreep team id (reep_t + 8 hex characters); null when no reep row is this club. No reep_id appears on two ESPN teams.
reep_nameStringClub name as reep records it (e.g. 'Manchester United F.C.').
reep_countryStringCountry reep records for the club ('United Kingdom' for English clubs, 'Wales' for some Welsh ones).
key_wikidataStringWikidata entity id of the club (e.g. 'Q18656').
key_transfermarktStringTransfermarkt club id, digits as text (e.g. '985').
key_fbrefStringFBref squad id (8 hex characters).
key_soccerwayStringSoccerway's numeric id for the club, as text (e.g. '725' for Hull City).
key_optaStringOpta team UUID (25 alphanumeric characters).
key_opta_numericStringOpta numeric team id.
key_kickerStringkicker.de club slug.
key_flashscoreStringFlashscore's slug/id path for the club (e.g. 'liverpool/lId4TMwf'); set for only a few clubs.
key_sofascoreStringSofascore's id for the club; the register release bundled here carries none for these clubs, so every row is null.
key_soccerbaseStringSoccerbase's numeric id for the club, as text (e.g. '1310' for Hull City).
key_uefaStringUEFA's numeric club id (uefa.com), as text (e.g. '2600537' for Hull City).
key_footballdatabase_euStringfootballdatabase.eu club id.
key_worldfootballStringworldfootball.net club slug.
key_playmakerstatsStringplaymakerstats.com team id.
key_clubeloStringClubElo club name (the key its ratings use, e.g. 'ManUnited').
key_sportmonksStringSportmonks' numeric team id, as text (e.g. '22' for Hull City).
key_api_footballStringAPI-Football team id.
key_sofifaStringSoFIFA's numeric team id (the EA FC ratings site), as text (e.g. '1' for Arsenal).
key_fotmobStringFotMob's numeric team id, as text (e.g. '10204' for Brighton & Hove Albion).
key_thesportsdbStringTheSportsDB's numeric team id, as text (e.g. '133617' for Hull City).
key_understatStringUnderstat's numeric team id, as text (e.g. '244' for Brentford); null for clubs Understat does not cover.
key_capologyStringCapology club slug.
match_methodStringHow the ESPN team was tied to reep. 'key_espn' (reep already carries this ESPN id), 'name' (exactly one reep row in the league's country shares a normalized name or alias), 'review' (settled by hand in tools/soccer_espn_reep_overrides.yaml), 'unmatched' (reviewed; no reep row is this club, reep columns null).

Raises

ExceptionDescription
ValueErrorIf league is not one of the covered league slugs.

Example

from sportsdataverse.soccer import soccer_espn_reep_team_crosswalk
xw = soccer_espn_reep_team_crosswalk()
print(xw.shape)

# One league, as pandas

epl = soccer_espn_reep_team_crosswalk(league="eng.1", return_as_pandas=True)

# Pipeline next step (one line)

xw.select("espn_team_id", "key_transfermarkt", "key_fbref").drop_nulls("key_transfermarkt")

Transfermarkt dataset (CC0)​

load_soccer_transfermarkt_clubs​

load_soccer_transfermarkt_clubs(*, return_as_pandas: 'bool' = False) -> 'pl.DataFrame | pd.DataFrame'

Load the CC0 Transfermarkt clubs table: one row per club of the first-tier leagues the dataset covers.

About 800 clubs, each with its league, squad profile and stadium as of its last season in the dataset. A snapshot current to 2026-07-06 (not refreshed), read on every call from the release mirror. Licence: CC0 1.0.

Parameters

ParameterTypeDefaultDescription
return_as_pandasboolFalseReturn a pandas DataFrame instead of polars.

Returns

polars.DataFrame | pandas.DataFrame: one row per club_id (Int64), the id soccer_espn_transfermarkt_team_crosswalk maps ESPN teams to. A column holding a value of another type comes back as text with a SchemaDriftWarning.

col_nametypedescription
club_idInt64Transfermarkt club id (Int64); the club_id of soccer_espn_transfermarkt_team_crosswalk.
club_codeStringTransfermarkt URL slug of the club (e.g. 'fc-barcelona').
nameStringClub name as Transfermarkt writes it (e.g. 'FC Barcelona').
domestic_competition_idStringTransfermarkt id of the club's domestic league (e.g. 'ES1'); joins competition_id of load_soccer_transfermarkt_competitions.
squad_sizeInt64Players in the club's squad in its last season in the dataset.
average_ageFloat64Average age of that squad, in years.
foreigners_numberInt64Players in that squad without the club's nationality.
foreigners_percentageFloat64foreigners_number as a percentage of squad_size; null when Transfermarkt shows none.
national_team_playersInt64Players in that squad capped by a senior national team.
stadium_nameStringName of the club's home stadium.
stadium_seatsInt64Seating capacity of that stadium.
net_transfer_recordStringNet transfer balance as Transfermarkt displays it, text with currency and unit (e.g. '+€5.90m', '€-25.00m').
coach_nameStringHead coach Transfermarkt lists; null for about half the clubs.
last_seasonInt64Start year of the club's last season in a covered competition (2025 = 2025-26).
urlStringTransfermarkt page of the club.

Raises

ExceptionDescription
ValueErrorThe original source answered 400 / 422.
NoDataErrorThe original source answered 404 (the file moved).
AssetFetchErrorThe original source, read when the release mirror cannot be (with a warning), failed (429, 5xx, a dropped connection), returned something other than a readable gzip CSV with rows, or lacks a column this loader types.

Example

from sportsdataverse.soccer import load_soccer_transfermarkt_clubs
clubs = load_soccer_transfermarkt_clubs()

# ESPN Premier League teams with their Transfermarkt club rows

from sportsdataverse.soccer import soccer_espn_transfermarkt_team_crosswalk
soccer_espn_transfermarkt_team_crosswalk(league="eng.1").join(clubs, on="club_id", how="left")

load_soccer_transfermarkt_competitions​

load_soccer_transfermarkt_competitions(*, return_as_pandas: 'bool' = False) -> 'pl.DataFrame | pd.DataFrame'

Load the CC0 Transfermarkt competitions table: the leagues and cups the dataset covers.

65 competitions: first-tier domestic leagues, domestic cups and international club competitions, read on every call from the release mirror. Licence: CC0 1.0.

Parameters

ParameterTypeDefaultDescription
return_as_pandasboolFalseReturn a pandas DataFrame instead of polars.

Returns

polars.DataFrame | pandas.DataFrame: one row per competition_id (text, e.g. "GB1"), the id the clubs and players tables carry as domestic_competition_id / current_club_domestic_competition_id.

col_nametypedescription
competition_idStringTransfermarkt competition id (e.g. 'GB1', 'CL').
competition_codeStringTransfermarkt URL slug of the competition (e.g. 'premier-league').
nameStringCompetition name as its slug (e.g. 'premier-league').
sub_typeStringKind of competition (e.g. 'first_tier', 'domestic_cup', 'uefa_champions_league', 'world_cup').
typeStringCompetition group - 'domestic_league', 'domestic_cup', 'international_cup', 'national_team_competition' or 'other'.
country_idInt64Transfermarkt country id (Int64); -1 for international competitions.
country_nameStringCountry name; null for international competitions.
domestic_league_codeStringId of the country's first-tier league; null for international competitions.
confederationStringConfederation as Transfermarkt names it ('europa', 'amerika', 'asien', 'afrika', 'fifa').
total_clubsInt64Clubs in the competition; null for some cups and national-team competitions.
urlStringTransfermarkt page of the competition.

Raises

ExceptionDescription
ValueErrorThe original source answered 400 / 422.
NoDataErrorThe original source answered 404 (the file moved).
AssetFetchErrorThe original source, read when the release mirror cannot be (with a warning), failed (429, 5xx, a dropped connection), returned something other than a readable gzip CSV with rows, or lacks a column this loader types.

Example

from sportsdataverse.soccer import load_soccer_transfermarkt_competitions
comps = load_soccer_transfermarkt_competitions()

# First-tier leagues only

import polars as pl
comps.filter(pl.col("sub_type") == "first_tier")

load_soccer_transfermarkt_player_valuations​

load_soccer_transfermarkt_player_valuations(*, return_as_pandas: 'bool' = False) -> 'pl.DataFrame | pd.DataFrame'

Load the CC0 Transfermarkt market-value history: one row per player and valuation date.

About 656,000 valuations, from 2000 to 2026-06-12 (the snapshot is not refreshed), read on every call from the release mirror. Licence: CC0 1.0.

Parameters

ParameterTypeDefaultDescription
return_as_pandasboolFalseReturn a pandas DataFrame instead of polars.

Returns

polars.DataFrame | pandas.DataFrame: one row per (player_id, date); player_id and current_club_id are Int64 and join the players and clubs tables. A column holding a value of another type comes back as text with a SchemaDriftWarning.

col_nametypedescription
player_idInt64Transfermarkt player id (Int64); joins load_soccer_transfermarkt_players.
dateDateDate of the valuation (2000-01-20 to 2026-06-12 in the snapshot).
market_value_in_eurInt64Market value Transfermarkt assigned on that date, in euros.
current_club_nameStringClub the player was at on that date ('Unknown' when Transfermarkt does not say).
current_club_idInt64Transfermarkt id of that club (Int64).
player_club_domestic_competition_idStringDomestic league id of that club (e.g. 'BE1'); null for clubs outside the covered leagues.

Raises

ExceptionDescription
ValueErrorThe original source answered 400 / 422.
NoDataErrorThe original source answered 404 (the file moved).
AssetFetchErrorThe original source, read when the release mirror cannot be (with a warning), failed (429, 5xx, a dropped connection), returned something other than a readable gzip CSV with rows, or lacks a column this loader types.

Example

from sportsdataverse.soccer import load_soccer_transfermarkt_player_valuations
values = load_soccer_transfermarkt_player_valuations()

# One player's value curve

import polars as pl
values.filter(pl.col("player_id") == 418560).sort("date")

load_soccer_transfermarkt_players​

load_soccer_transfermarkt_players(*, return_as_pandas: 'bool' = False) -> 'pl.DataFrame | pd.DataFrame'

Load the CC0 Transfermarkt players table: one row per player, with current club and market value.

About 50,000 players: everyone who appeared for a club of the first-tier leagues the dataset covers (Premier League, LaLiga, Bundesliga, Serie A, Ligue 1, MLS, Liga MX and about 20 more). A snapshot current to 2026-07-06 (not refreshed), read on every call from the release mirror. Licence: CC0 1.0.

Parameters

ParameterTypeDefaultDescription
return_as_pandasboolFalseReturn a pandas DataFrame instead of polars.

Returns

polars.DataFrame | pandas.DataFrame: one row per player_id (Int64). current_club_id (Int64) joins club_id of load_soccer_transfermarkt_clubs and of soccer_espn_transfermarkt_team_crosswalk. A column holding a value of another type comes back as text with a SchemaDriftWarning.

col_nametypedescription
player_idInt64Transfermarkt player id (Int64), unique in the table.
first_nameStringGiven name; null when Transfermarkt shows one name only.
last_nameStringFamily name (or the single name).
nameStringFull name as Transfermarkt shows it.
last_seasonInt64Start year of the last season the player appeared in a covered competition (2025 = 2025-26).
current_club_idInt64Transfermarkt id of the player's club at the snapshot (Int64); joins club_id.
player_codeStringTransfermarkt URL slug of the player.
country_of_birthStringCountry of birth.
city_of_birthStringCity of birth, as Transfermarkt writes it (may carry trailing non-breaking spaces).
country_of_citizenshipStringFirst citizenship Transfermarkt lists.
date_of_birthDatePlayer's date of birth as Transfermarkt records it (Date); null for about 50 players.
sub_positionStringDetailed position (e.g. 'Centre-Forward', 'Left-Back').
positionStringPosition group - 'Goalkeeper', 'Defender', 'Midfield', 'Attack' or 'Missing'.
footStringPreferred foot - 'right', 'left' or 'both'; null when unknown.
height_in_cmInt64Height in centimetres.
contract_expiration_dateDateDate the player's current contract ends; null when unknown.
agent_nameStringPlayer's agency as Transfermarkt lists it.
image_urlStringURL of the player's Transfermarkt portrait.
international_capsInt64Senior caps for current_national_team_id; null when uncapped.
international_goalsInt64Senior international goals; null when uncapped.
current_national_team_idInt64Transfermarkt id of the national team the player represents (Int64); null when none.
urlStringTransfermarkt page of the player.
current_club_domestic_competition_idStringDomestic league id of current_club_id (e.g. 'GB1').
current_club_nameStringName of current_club_id as Transfermarkt writes it (often the legal name, e.g. 'Società Sportiva Lazio S.p.A.').
market_value_in_eurInt64Latest Transfermarkt market value, in euros; null when none is listed.
highest_market_value_in_eurInt64Highest market value Transfermarkt has recorded for the player, in euros.

Raises

ExceptionDescription
ValueErrorThe original source answered 400 / 422.
NoDataErrorThe original source answered 404 (the file moved).
AssetFetchErrorThe original source, read when the release mirror cannot be (with a warning), failed (429, 5xx, a dropped connection), returned something other than a readable gzip CSV with rows, or lacks a column this loader types.

Example

from sportsdataverse.soccer import load_soccer_transfermarkt_players
players = load_soccer_transfermarkt_players()
print(players.shape)

# Most valuable players

players.sort("market_value_in_eur", descending=True, nulls_last=True).head(10)

load_soccer_transfermarkt_transfers​

load_soccer_transfermarkt_transfers(*, return_as_pandas: 'bool' = False) -> 'pl.DataFrame | pd.DataFrame'

Load the CC0 Transfermarkt transfers table: one row per player move between clubs, with its fee.

About 175,000 transfers involving the clubs the dataset covers, to the 2025-26 season (the snapshot is current to 2026-07-06 and not refreshed), read on every call from the release mirror. Licence: CC0 1.0.

Parameters

ParameterTypeDefaultDescription
return_as_pandasboolFalseReturn a pandas DataFrame instead of polars.

Returns

polars.DataFrame | pandas.DataFrame: one row per transfer. player_id, from_club_id and to_club_id are Int64 Transfermarkt ids. A column holding a value of another type comes back as text with a SchemaDriftWarning.

col_nametypedescription
player_idInt64Transfermarkt player id (Int64).
transfer_dateDateDate the move takes effect; a pre-agreed future move can be dated years ahead.
transfer_seasonStringSeason of the move as Transfermarkt writes it (e.g. '25/26').
from_club_idInt64Transfermarkt id of the selling club (Int64).
to_club_idInt64Transfermarkt id of the buying club (Int64).
from_club_nameStringName of the selling club.
to_club_nameStringName of the buying club.
transfer_feeFloat64Fee in euros; 0 for a free transfer, null when Transfermarkt shows no fee (undisclosed or unknown).
market_value_in_eurFloat64Player's Transfermarkt market value at the time of the move, in euros; Float64 because the file writes it with decimals, e.g. '700000.000').
player_nameStringName of the player.

Raises

ExceptionDescription
ValueErrorThe original source answered 400 / 422.
NoDataErrorThe original source answered 404 (the file moved).
AssetFetchErrorThe original source, read when the release mirror cannot be (with a warning), failed (429, 5xx, a dropped connection), returned something other than a readable gzip CSV with rows, or lacks a column this loader types.

Example

from sportsdataverse.soccer import load_soccer_transfermarkt_transfers
moves = load_soccer_transfermarkt_transfers()

# The largest fees of one season

import polars as pl
moves.filter(pl.col("transfer_season") == "25/26").sort("transfer_fee", descending=True, nulls_last=True)

soccer_espn_transfermarkt_player_crosswalk​

soccer_espn_transfermarkt_player_crosswalk(league: 'str | None' = None, *, return_as_pandas: 'bool' = False) -> 'pl.DataFrame | pd.DataFrame'

ESPN soccer athlete id -> Transfermarkt player_id, for the first-tier leagues' current ESPN rosters.

One row per athlete on the ESPN rosters (fetched 2026-11-27) of the eng.1, esp.1, ger.1, ita.1, fra.1, usa.1 and mex.1 teams whose Transfermarkt club is in the dataset: 4,346 athletes, 3,661 resolved (84%). The table ships with sdv-py; no request is made. An athlete is resolved by birth date and name against every Transfermarkt player: exactly one player with the same birth date and a shared name token, or, among several, the one with the athlete's citizenship. A 1 January birth date is too common a stand-in to count alone, so such an athlete is resolved only when exactly one same-date, same-name player also plays for the team's Transfermarkt club (or moved to it from 2025-07-01) or shares the citizenship. No player is matched to two athletes, and where the reep register carries both ids they agree on 99% of 2,478 pairs. Known limits: an ESPN birth date that belongs to a same-surname player resolves to that player (about a dozen athletes found at review), first names are not compared, and ESPN and Transfermarkt spell some countries differently ("USA", "Ivory Coast"), so the citizenship checks never fire for those athletes. The Transfermarkt data ends in July 2026, so a player who joined later can resolve with his previous club.

Parameters

ParameterTypeDefaultDescription
leaguestr | NoneNoneOne of the seven ESPN league slugs above, to keep that league's rows; None (default) returns all.
return_as_pandasboolFalseReturn a pandas DataFrame instead of polars.

Returns

polars.DataFrame | pandas.DataFrame: one row per espn_athlete_id (Utf8, unique). player_id (Int64) joins load_soccer_transfermarkt_players().player_id and load_soccer_transfermarkt_player_valuations(); it is null, with match_method == "unmatched", when no rule resolved the athlete.

col_nametypedescription
espn_athlete_idStringESPN soccer athlete id, digits as text (Utf8, as the ESPN soccer roster frames carry it); unique in the table.
espn_team_idStringESPN team whose roster listed the athlete on 2026-11-27 (Utf8).
espn_leagueStringESPN league slug of that team (eng.1, esp.1, ger.1, ita.1, fra.1, usa.1, mex.1).
espn_date_of_birthDateBirth date ESPN gives for the athlete; null when ESPN gives none (the athlete is then unmatched).
player_idInt64Transfermarkt player id (Int64); joins player_id of load_soccer_transfermarkt_players and load_soccer_transfermarkt_player_valuations. Null when unmatched; never on two athletes.
tm_nameStringTransfermarkt name of the matched player; null when unmatched.
match_methodStringHow the athlete was resolved. 'name_dob' (the only Transfermarkt player with the same birth date and a shared name token), 'name_dob_nationality' (several such players, one with the athlete's citizenship), 'name_jan1_club' / 'name_jan1_nationality' (a 1 January birth date, resolved only because exactly one such player is also at the team's Transfermarkt club or shares the citizenship), or 'unmatched'.

Raises

ExceptionDescription
ValueErrorIf league is not one of the covered league slugs.

Example

from sportsdataverse.soccer import soccer_espn_transfermarkt_player_crosswalk
xw = soccer_espn_transfermarkt_player_crosswalk()
print(xw.shape)

# One league, as pandas

epl = soccer_espn_transfermarkt_player_crosswalk(league="eng.1", return_as_pandas=True)

# Market values for ESPN athletes

from sportsdataverse.soccer import load_soccer_transfermarkt_players
xw = soccer_espn_transfermarkt_player_crosswalk()
xw.join(load_soccer_transfermarkt_players(), on="player_id").select("espn_athlete_id", "market_value_in_eur")

soccer_espn_transfermarkt_team_crosswalk​

soccer_espn_transfermarkt_team_crosswalk(league: 'str | None' = None, *, return_as_pandas: 'bool' = False) -> 'pl.DataFrame | pd.DataFrame'

ESPN soccer team id -> Transfermarkt club_id, for the leagues of the ESPN <-> reep crosswalk.

Read from the bundled ESPN <-> reep table (soccer_espn_reep_team_crosswalk), whose reep rows carry the Transfermarkt id, plus a reviewed id for a club whose reep row has none. No request is made. A newly promoted club can carry a club_id the Transfermarkt clubs table does not list: that snapshot ends in July 2026 and covers first tiers only.

Parameters

ParameterTypeDefaultDescription
leaguestr | NoneNoneAn ESPN league slug of the reep crosswalk (eng.1, eng.2, esp.1, ger.1, ita.1, fra.1, usa.1, mex.1); None (default) returns every league.
return_as_pandasboolFalseReturn a pandas DataFrame instead of polars.

Returns

polars.DataFrame | pandas.DataFrame: one row per espn_team_id (Utf8, unique; joins the ESPN soccer frames' team ids). club_id is Int64, null when no Transfermarkt id is known, and never on two ESPN teams.

col_nametypedescription
espn_team_idStringESPN soccer team id, digits as text (Utf8, as the ESPN soccer frames carry team ids); unique.
espn_leagueStringESPN league slug the team was listed under when the ESPN <-> reep crosswalk was built.
espn_display_nameStringESPN display name of the team at that build.
club_idInt64Transfermarkt club id (Int64); joins club_id of load_soccer_transfermarkt_clubs and current_club_id of load_soccer_transfermarkt_players. Null when no Transfermarkt id is known; never on two ESPN teams.
match_methodStringWhere club_id comes from - 'reep' (the reep row's Transfermarkt id) or 'review' (reviewed by hand because the reep row has none); null with club_id.

Raises

ExceptionDescription
ValueErrorIf league is not one of the covered league slugs.

Example

from sportsdataverse.soccer import soccer_espn_transfermarkt_team_crosswalk
tm = soccer_espn_transfermarkt_team_crosswalk(league="eng.1")

# Current Transfermarkt squads of the ESPN Premier League teams

from sportsdataverse.soccer import load_soccer_transfermarkt_players
tm.join(load_soccer_transfermarkt_players(), left_on="club_id", right_on="current_club_id")

Analytics​

soccer_game_story​

soccer_game_story(summaries: 'dict | list[dict]', *, return_as_pandas: 'bool' = False) -> 'dict[str, pl.DataFrame] | dict[str, pd.DataFrame]'

How the winner won it, for one or many soccer matches: edges in goals, the moment, halves, runs, performers.

Parameters

ParameterTypeDefaultDescription
summariesdict | list[dict]One raw ESPN match summary or a list of them (espn_soccer_summary(league, event_id, return_parsed=False)), any league.
return_as_pandasboolFalseReturn pandas frames instead of polars.

Returns

{"summary", "edges", "moment", "periods", "runs", "performers"}, the frames of ~sportsdataverse._common.game_story.GAME_STORY_SCHEMAS: the goals by kind (adding up to the margin exactly) and shots on target, in goals and ranked; the winner's go-ahead-for-good goal (rule deciding_score); H1, H2, ET1, ET2; each side's largest unanswered run of goals; the goals-plus-assists leader. A summary without both teams' final score is skipped; one without a game id is skipped with a UserWarning.

summary:

col_nametypedescription
game_idInt64The match's ESPN event id.
home_team_idInt64Home team's ESPN team id.
away_team_idInt64Away team's ESPN team id.
home_scoreInt64Home team's official final score.
away_scoreInt64Away team's official final score.
winner_team_idInt64Winning team's id; null on a tie.
loser_team_idInt64Losing team's id; null on a tie.
marginInt64Winner's final score less the loser's; 0 on a tie.
decidedBooleanTrue when the game has a winner (false on a tie).
periods_agreeBooleanTrue when the period sums (from the play-by-play's running score) equal the official final; false flags a source whose plays end on another score.
n_periodsInt64Periods played, overtimes included.
overtimeBooleanTrue when the game went past regulation.

edges:

col_nametypedescription
game_idInt64The match's ESPN event id.
winner_team_idInt64Winning team's id (null on a tie, where the edges read from the home side's view).
loser_team_idInt64Losing team's id (null on a tie).
edgeStringEdge name. Accounting: open_play_goals, set_piece_goals (direct free kicks and goals following a corner or set piece), penalty_goals, own_goals_for; together the margin exactly. Split: shots_on_target, priced at the match's goals per shot on target.
kindStringaccounting for edges that split the game between them (their points_worth add up to the margin, exactly or nearly; see the function's docstring), split for overlapping cuts.
unitStringAlways goals: the scoring unit the edges are priced in.
winner_valueFloat64Winner's value for the edge in the edge's own unit: points for a points edge, a rate for a rate edge.
loser_valueFloat64Loser's value for the edge, in the same unit as winner_value.
points_worthFloat64The winner's edge in the sport's scoring unit: the winner's points from the edge less the loser's. Positive favours the winner.
rankInt64Rank of the edge within the game by points_worth, 1 = largest; equal worths keep the edge list's order.

moment:

col_nametypedescription
game_idInt64The match's ESPN event id.
play_idInt64ESPN key-event id of the deciding goal (null for a shootout's closing row).
orderInt64The play's position in the game's play order.
periodInt64Period of the play.
clockStringGame clock of the play as the source shows it.
team_idInt64Team of the play: the event's team (hockey), the batting team (baseball), the scoring team (soccer).
textStringPlay description as the source writes it.
wpaFloat64Home win probability after the play less before it.
winner_wpaFloat64The same change from the winner's side (null on a tie).
home_scoreInt64Home score after the play.
away_scoreInt64Away score after the play.
ruleStringAlways deciding_score: no in-game win-probability model ships for this league, so the moment is the winner's go-ahead-for-good score.

periods:

col_nametypedescription
game_idInt64The match's ESPN event id.
periodInt64Period number, from 1; overtimes follow regulation.
period_labelStringH1, H2, then ET1, ET2 for extra time (a penalty shootout is not a period).
is_overtimeBooleanTrue for a period after regulation.
home_ptsInt64Home points in the period: its last running score less the previous period's.
away_ptsInt64Away points in the period.
home_cumInt64Home running score at the end of the period.
away_cumInt64Away running score at the end of the period.

runs:

col_nametypedescription
game_idInt64The match's ESPN event id.
team_idInt64Team that made the run.
pointsInt64The side's largest unanswered run: points it scored in a row with no score by the other side (a score correction stays in the run and counts against its side).
start_orderInt64Play order of the run's first score.
end_orderInt64Play order of the run's last score.
start_periodInt64Period of the run's first score.
end_periodInt64Period of the run's last score.
home_score_afterInt64Home score at the end of the run.
away_score_afterInt64Away score at the end of the run.

performers:

col_nametypedescription
game_idInt64The match's ESPN event id.
team_idInt64Team of the top performer.
player_idInt64The side's top performer's player id.
player_nameStringPlayer's display name.
metricStringAlways goals_assists: goals plus assists, the metric the performer is chosen by.
valueFloat64The player's goals plus assists from the goal events (ties go to goals).

Example

from sportsdataverse.soccer.soccer_espn_ext import espn_soccer_summary
from sportsdataverse.soccer.soccer_game_story import soccer_game_story
story = soccer_game_story(espn_soccer_summary("eng.1", event_id=704279, return_parsed=False))
story["edges"]

# A matchday

from sportsdataverse.soccer.soccer_espn_ext import espn_soccer_scoreboard
day = espn_soccer_scoreboard("eng.1", dates="20250525", return_parsed=False)
ids = [e["id"] for e in day["events"]]
soccer_game_story([espn_soccer_summary("eng.1", event_id=i, return_parsed=False) for i in ids])