Positions
In soccer, while players are not bound by strict rules about where they must be positioned on the field, there are traditionally recognized positions that players tend to stay closest to during a match. These positions are commonly tracked by various providers, though each provider may use different naming conventions and classifications. To offer consistency across different data sources, kloppy implements a standardized PositionType with support for the following positions:
Each PositionType has a unique name and code.
As you might have noticed, positions are ordered hierarchically. This allows you to work on different levels of granularity, from broader categories like "Defender" or "Midfielder" to more specific positions like "Left Back" or "Center Midfield."
Each PositionType has a .parent attribute to get the position's broader category.
You can check if a position belongs to a broader category using the is_subtype_of method.
A player's position can change throughout a game. A player's positions throughout the game are stored in the .positions attributes as a [TimeContainer][kloppy.domain.TimeContainer]. This container maps Time instances to positions, allowing lookups and time range queries:
.ranges(): list positions throughout the game..value_at(time): get position at a specific time..at_start(): retrieve the starting position..last(): retrieve the last position.
You can conveniently retrieve a player's starting position or a player's position at a certain time in the match.
Note that a player's position will be None if not on the pitch.