In [1]:
Copied!
from kloppy import sportec
dataset = sportec.load_event(
event_data="../../kloppy/tests/files/sportec_events.xml",
meta_data="../../kloppy/tests/files/sportec_meta.xml",
# Optional arguments
coordinates="sportec",
event_types=["pass", "shot"]
)
dataset.to_df().head()
from kloppy import sportec
dataset = sportec.load_event(
event_data="../../kloppy/tests/files/sportec_events.xml",
meta_data="../../kloppy/tests/files/sportec_meta.xml",
# Optional arguments
coordinates="sportec",
event_types=["pass", "shot"]
)
dataset.to_df().head()
Out[1]:
event_id | event_type | result | success | period_id | timestamp | end_timestamp | ball_state | ball_owning_team | team_id | player_id | coordinates_x | coordinates_y | end_coordinates_x | end_coordinates_y | receiver_player_id | set_piece_type | body_part_type | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 17364900000006 | PASS | COMPLETE | True | 1 | 0.000 | None | alive | None | DFL-CLU-000004 | DFL-OBJ-0000SP | 56.41 | 68.00 | 77.75 | 38.71 | DFL-OBJ-0000ZS | KICK_OFF | None |
1 | 17364900000007 | PASS | COMPLETE | True | 1 | 3.123 | None | alive | None | DFL-CLU-000004 | DFL-OBJ-0000ZS | 73.94 | 37.21 | NaN | NaN | DFL-OBJ-002G3I | None | None |
2 | 17364900000014 | PASS | COMPLETE | True | 1 | 31.797 | None | alive | None | DFL-CLU-00000A | DFL-OBJ-00017V | 35.57 | 68.00 | 21.24 | 28.58 | DFL-OBJ-0027B9 | THROW_IN | None |
3 | 17364900000031 | SHOT | BLOCKED | False | 1 | 79.480 | None | alive | None | DFL-CLU-000004 | DFL-OBJ-002706 | 21.24 | 28.58 | NaN | NaN | None | None | RIGHT_FOOT |
4 | 17364900000036 | PASS | INCOMPLETE | False | 1 | 95.173 | None | alive | None | DFL-CLU-000004 | DFL-OBJ-002G3I | 8.72 | 4.21 | NaN | NaN | None | None | None |
Load local tracking files¶
In [3]:
Copied!
from kloppy import sportec
dataset = sportec.load_tracking(
raw_data="../../kloppy/tests/files/sportec_positional.xml",
meta_data="../../kloppy/tests/files/sportec_meta.xml",
# Optional arguments
sample_rate=1,
limit=10,
coordinates="sportec",
only_alive=False
)
dataset.to_df().head()
from kloppy import sportec
dataset = sportec.load_tracking(
raw_data="../../kloppy/tests/files/sportec_positional.xml",
meta_data="../../kloppy/tests/files/sportec_meta.xml",
# Optional arguments
sample_rate=1,
limit=10,
coordinates="sportec",
only_alive=False
)
dataset.to_df().head()
Out[3]:
period_id | timestamp | frame_id | ball_state | ball_owning_team_id | ball_x | ball_y | ball_z | ball_speed | DFL-OBJ-002G3I_x | ... | DFL-OBJ-002G3I_d | DFL-OBJ-002G3I_s | DFL-OBJ-002G5S_x | DFL-OBJ-002G5S_y | DFL-OBJ-002G5S_d | DFL-OBJ-002G5S_s | DFL-OBJ-002FVJ_x | DFL-OBJ-002FVJ_y | DFL-OBJ-002FVJ_d | DFL-OBJ-002FVJ_s | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1 | 0.00 | 10000 | dead | DFL-CLU-000004 | 2.69 | 0.26 | 0.06 | 0.00 | 0.35 | ... | None | 0.00 | NaN | NaN | None | NaN | NaN | NaN | None | NaN |
1 | 1 | 0.04 | 10001 | alive | DFL-CLU-00000A | 3.41 | 0.26 | 0.08 | 65.59 | 0.34 | ... | None | 1.74 | NaN | NaN | None | NaN | NaN | NaN | None | NaN |
2 | 1 | 0.08 | 10002 | alive | DFL-CLU-000004 | 4.22 | 0.33 | 0.09 | 65.16 | 0.32 | ... | None | 1.76 | NaN | NaN | None | NaN | NaN | NaN | None | NaN |
3 | 1 | 0.12 | 10003 | alive | DFL-CLU-000004 | 5.02 | 0.38 | 0.09 | 74.34 | 0.31 | ... | None | 1.78 | NaN | NaN | None | NaN | NaN | NaN | None | NaN |
4 | 1 | 0.16 | 10004 | alive | DFL-CLU-000004 | 5.79 | 0.44 | 0.08 | 73.58 | 0.29 | ... | None | 1.80 | NaN | NaN | None | NaN | NaN | NaN | None | NaN |
5 rows × 21 columns
Load open data¶
There are 7 games of open Sportec Open DFL Tracking and Event Data (Bassek et al. 2025).
You can use the following match ids to load these games automatically with kloppy.
match_id | home | away |
---|---|---|
J03WMX | 1. FC Köln | FC Bayern München |
J03WN1 | VfL Bochum 1848 | Bayer 04 Leverkusen |
J03WPY | Fortuna Düsseldorf | 1. FC Nürnberg |
J03WOH | Fortuna Düsseldorf | SSV Jahn Regensburg |
J03WQQ | Fortuna Düsseldorf | FC St. Pauli |
J03WOY | Fortuna Düsseldorf | F.C. Hansa Rostock |
J03WR9 | Fortuna Düsseldorf | 1. FC Kaiserslautern |
In [ ]:
Copied!
from kloppy import sportec
match_id = "J03WMX"
event_dataset = sportec.load_open_event_data(match_id=match_id)
tracking_dataset = sportec.load_open_tracking_data(match_id=match_id)
from kloppy import sportec
match_id = "J03WMX"
event_dataset = sportec.load_open_event_data(match_id=match_id)
tracking_dataset = sportec.load_open_tracking_data(match_id=match_id)
Load remote files¶
Kloppy supports remote files through fsspec
FileSystem under the hood. This allows you to work with files in AWS S3, Google Cloud, Azure Blob, HDFS, FTP, and SFTP without extra tools.
For example you can pass:
- Individual s3 file paths: (e.g
raw_data=s3://.../sportec_positional.xml
)
Note: Kloppy might throw an the first time to help you identify missing cloud specific dependencies like s3fs
.
In [ ]:
Copied!
from kloppy import sportec
dataset = sportec.load_tracking(
raw_data="s3://.../sportec_positional.xml",
meta_data="s3://.../sportec_meta.xml",
# Optional arguments
sample_rate=1,
limit=10,
coordinates="sportec",
only_alive=False
)
from kloppy import sportec
dataset = sportec.load_tracking(
raw_data="s3://.../sportec_positional.xml",
meta_data="s3://.../sportec_meta.xml",
# Optional arguments
sample_rate=1,
limit=10,
coordinates="sportec",
only_alive=False
)