pysoccer package

Submodules

pysoccer.attributes module

class pysoccer.attributes.Formation(lineup: List[pysoccer.attributes.Player], bench: List[pysoccer.attributes.Player])

Bases: object

Class defining the formation of a given team in a match.

bench: List[pysoccer.attributes.Player]
lineup: List[pysoccer.attributes.Player]
class pysoccer.attributes.Player(player_id: int, shirt_number: int, played_minutes: int, yellow_cards: int, red_cards: int, own_goals: int, goals: int)

Bases: object

Class defining a soccer player.

goals: int
own_goals: int
played_minutes: int
player_id: int
red_cards: int
shirt_number: int
yellow_cards: int
class pysoccer.attributes.Point(x: float, y: float)

Bases: object

Class defining a point on the pitch.

x: float
y: float
class pysoccer.attributes.ResultType(value)

Bases: enum.Enum

Class defining the possible results of an event.

FAILURE = 'FAILURE'
NEUTRAL = 'NEUTRAL'
SUCCESS = 'SUCCESS'
UNDEFINED = 'UNDEFINED'
class pysoccer.attributes.Substitution(player_in: int, player_out: int, timestamp: float)

Bases: object

Class defining a substitution during a match.

player_in: int
player_out: int
timestamp: float
class pysoccer.attributes.Team(team_id: int, coach_id: int, score: int, formation: pysoccer.attributes.Formation, substitutions: List[pysoccer.attributes.Substitution])

Bases: object

Class defining a soccer team.

coach_id: int
formation: pysoccer.attributes.Formation
score: int
substitutions: List[pysoccer.attributes.Substitution]
team_id: int

pysoccer.base module

class pysoccer.base.EventSerializer

Bases: abc.ABC

Class to wrap all the event serializers.

abstract serialize(input: List)

Function that serializes the events given in input.

class pysoccer.base.MatchSerializer

Bases: abc.ABC

Class to wrap all the match serializers.

abstract serialize(input: List)

Functoin that serializes the matches given in input.

pysoccer.event module

class pysoccer.event.Event(event_id: int, team_id: int, player_id: int, match_id: int, period: str, timestamp: float, start_position: pysoccer.attributes.Point, end_position: pysoccer.attributes.Point, outcome: pysoccer.attributes.ResultType, label: str, tags: List[str], phase_id: int, phase_end: str, phase_possessing_team: int)

Bases: object

Class defining a standardized event.

end_position: pysoccer.attributes.Point
event_id: int
get_position(pitch_length: int, pitch_width: int, pitch_side: str)

Function that computes a player’s position on the field.

Parameters
  • pitch_length – the pitch’s length

  • pitch_width – the pitch’s width

  • pitch_side – the pitch’s side of the player’s team

label: str
match_id: int
outcome: pysoccer.attributes.ResultType
period: str
phase_end: str
phase_id: int
phase_possessing_team: int
player_id: int
start_position: pysoccer.attributes.Point
tags: List[str]
team_id: int
timestamp: float
to_dict()
class pysoccer.event.NotPossessionEvent(event_id: int, team_id: int, player_id: int, match_id: int, period: str, timestamp: float, start_position: pysoccer.attributes.Point, end_position: pysoccer.attributes.Point, outcome: pysoccer.attributes.ResultType, label: str, tags: List[str], phase_id: int, phase_end: str, phase_possessing_team: int, is_duel: bool = False, challenged_player: Optional[str] = None, is_foul: bool = False, card: Optional[str] = None)

Bases: pysoccer.event.Event

Class that specifies an event of a player of the not possessing team.

card: str = None
challenged_player: str = None
is_duel: bool = False
is_foul: bool = False
class pysoccer.event.PossessionEvent(event_id: int, team_id: int, player_id: int, match_id: int, period: str, timestamp: float, start_position: pysoccer.attributes.Point, end_position: pysoccer.attributes.Point, outcome: pysoccer.attributes.ResultType, label: str, tags: List[str], phase_id: int, phase_end: str, phase_possessing_team: int, is_duel: bool = False, challenged_player: Optional[str] = None, is_shot: bool = False, goal_position: Optional[str] = None, is_goal: bool = False, is_pass: bool = False, receiver_player_id: Optional[int] = None, is_assist: bool = False, is_keypass: bool = False)

Bases: pysoccer.event.Event

Class that specifies an event of a player of the possessing team.

challenged_player: str = None
goal_position: str = None
is_assist: bool = False
is_duel: bool = False
is_goal: bool = False
is_keypass: bool = False
is_pass: bool = False
is_shot: bool = False
receiver_player_id: int = None

pysoccer.match module

class pysoccer.match.Match(competition_id: int, round_id: int, season_id: int, date_utc: str, match_id: int, label: str, home_team: pysoccer.attributes.Team, away_team: pysoccer.attributes.Team, additional_attributes: ])

Bases: object

Class defining a match.

additional_attributes: ]
away_team: pysoccer.attributes.Team
competition_id: int
date_utc: str
home_team: pysoccer.attributes.Team
label: str
match_id: int
round_id: int
season_id: int

Module contents