In [1]:
Copied!
from kloppy import metrica
dataset = metrica.load_tracking_csv(
home_data="../../kloppy/tests/files/metrica_home.csv",
away_data="../../kloppy/tests/files/metrica_away.csv",
# Optional arguments
sample_rate=1/5,
limit=100,
coordinates="metrica"
)
dataset.to_df().head()
from kloppy import metrica
dataset = metrica.load_tracking_csv(
home_data="../../kloppy/tests/files/metrica_home.csv",
away_data="../../kloppy/tests/files/metrica_away.csv",
# Optional arguments
sample_rate=1/5,
limit=100,
coordinates="metrica"
)
dataset.to_df().head()
Out[1]:
period_id | timestamp | frame_id | ball_state | ball_owning_team_id | ball_x | ball_y | ball_z | home_11_x | home_11_y | ... | away_26_d | away_26_s | away_27_x | away_27_y | away_27_d | away_27_s | away_28_x | away_28_y | away_28_d | away_28_s | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1 | 0.00 | 1 | None | None | 0.45472 | 0.61291 | None | 0.00082 | 0.51762 | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
1 | 2 | 0.08 | 145006 | None | None | NaN | NaN | None | 0.90456 | 0.54644 | ... | NaN | NaN | 0.19754 | 0.54636 | NaN | NaN | 0.21798 | 0.18921 | NaN | NaN |
2 rows × 120 columns
Load remote csv tracking files¶
In [2]:
Copied!
from kloppy import metrica
dataset = metrica.load_tracking_csv(
home_data="https://raw.githubusercontent.com/metrica-sports/sample-data/master/data/Sample_Game_1/Sample_Game_1_RawTrackingData_Home_Team.csv",
away_data="https://raw.githubusercontent.com/metrica-sports/sample-data/master/data/Sample_Game_1/Sample_Game_1_RawTrackingData_Away_Team.csv",
# Optional arguments
sample_rate=1/5,
limit=100,
coordinates="metrica"
)
dataset.to_df().head()
from kloppy import metrica
dataset = metrica.load_tracking_csv(
home_data="https://raw.githubusercontent.com/metrica-sports/sample-data/master/data/Sample_Game_1/Sample_Game_1_RawTrackingData_Home_Team.csv",
away_data="https://raw.githubusercontent.com/metrica-sports/sample-data/master/data/Sample_Game_1/Sample_Game_1_RawTrackingData_Away_Team.csv",
# Optional arguments
sample_rate=1/5,
limit=100,
coordinates="metrica"
)
dataset.to_df().head()
Out[2]:
period_id | timestamp | frame_id | ball_state | ball_owning_team_id | ball_x | ball_y | ball_z | home_11_x | home_11_y | ... | away_22_d | away_22_s | away_23_x | away_23_y | away_23_d | away_23_s | away_24_x | away_24_y | away_24_d | away_24_s | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1 | 0.0 | 1 | None | None | 0.45472 | 0.61291 | None | 0.00082 | 0.51762 | ... | None | None | 0.43693 | 0.94998 | None | None | 0.37833 | 0.72617 | None | None |
1 | 1 | 0.2 | 6 | None | None | 0.55677 | 0.61091 | None | 0.00140 | 0.51762 | ... | None | None | 0.43504 | 0.95116 | None | None | 0.37557 | 0.72327 | None | None |
2 | 1 | 0.4 | 11 | None | None | 0.56504 | 0.69395 | None | 0.00085 | 0.51890 | ... | None | None | 0.43128 | 0.95690 | None | None | 0.36945 | 0.71909 | None | None |
3 | 1 | 0.6 | 16 | None | None | 0.57330 | 0.77700 | None | 0.00065 | 0.51916 | ... | None | None | 0.42728 | 0.96250 | None | None | 0.36360 | 0.71470 | None | None |
4 | 1 | 0.8 | 21 | None | None | 0.57247 | 0.79726 | None | 0.00066 | 0.51879 | ... | None | None | 0.42275 | 0.96700 | None | None | 0.35810 | 0.71129 | None | None |
5 rows × 96 columns
Load open tracking data¶
In [3]:
Copied!
from kloppy import metrica
dataset = metrica.load_open_data(
match_id=1,
# Optional arguments
sample_rate=1/5,
limit=100,
coordinates="metrica"
)
dataset.to_df().head()
from kloppy import metrica
dataset = metrica.load_open_data(
match_id=1,
# Optional arguments
sample_rate=1/5,
limit=100,
coordinates="metrica"
)
dataset.to_df().head()
Out[3]:
period_id | timestamp | frame_id | ball_state | ball_owning_team_id | ball_x | ball_y | ball_z | home_11_x | home_11_y | ... | away_22_d | away_22_s | away_23_x | away_23_y | away_23_d | away_23_s | away_24_x | away_24_y | away_24_d | away_24_s | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1 | 0.0 | 1 | None | None | 0.45472 | 0.61291 | None | 0.00082 | 0.51762 | ... | None | None | 0.43693 | 0.94998 | None | None | 0.37833 | 0.72617 | None | None |
1 | 1 | 0.2 | 6 | None | None | 0.55677 | 0.61091 | None | 0.00140 | 0.51762 | ... | None | None | 0.43504 | 0.95116 | None | None | 0.37557 | 0.72327 | None | None |
2 | 1 | 0.4 | 11 | None | None | 0.56504 | 0.69395 | None | 0.00085 | 0.51890 | ... | None | None | 0.43128 | 0.95690 | None | None | 0.36945 | 0.71909 | None | None |
3 | 1 | 0.6 | 16 | None | None | 0.57330 | 0.77700 | None | 0.00065 | 0.51916 | ... | None | None | 0.42728 | 0.96250 | None | None | 0.36360 | 0.71470 | None | None |
4 | 1 | 0.8 | 21 | None | None | 0.57247 | 0.79726 | None | 0.00066 | 0.51879 | ... | None | None | 0.42275 | 0.96700 | None | None | 0.35810 | 0.71129 | None | None |
5 rows × 96 columns
Load local EPTS tracking files¶
In [4]:
Copied!
from kloppy import metrica
dataset = metrica.load_tracking_epts(
meta_data="../../kloppy/tests/files/epts_metrica_metadata.xml",
raw_data="../../kloppy/tests/files/epts_metrica_tracking.txt",
# Optional arguments
sample_rate=1/5,
limit=100,
coordinates="metrica"
)
dataset.to_df().head()
from kloppy import metrica
dataset = metrica.load_tracking_epts(
meta_data="../../kloppy/tests/files/epts_metrica_metadata.xml",
raw_data="../../kloppy/tests/files/epts_metrica_tracking.txt",
# Optional arguments
sample_rate=1/5,
limit=100,
coordinates="metrica"
)
dataset.to_df().head()
Out[4]:
period_id | timestamp | frame_id | ball_state | ball_owning_team_id | ball_x | ball_y | ball_z | Track_1_x | Track_1_y | ... | Track_21_x | Track_21_y | Track_21_d | Track_21_s | Track_21_mapping | Track_22_x | Track_22_y | Track_22_d | Track_22_s | Track_22_mapping | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1 | 18.0 | 450 | None | None | 0.52867 | 0.70690 | None | 0.30602 | 0.97029 | ... | 0.39631 | 0.77277 | None | 3.338606 | 15.0 | NaN | NaN | None | NaN | 21.0 |
1 | 1 | 18.2 | 455 | None | None | 0.54588 | 0.71626 | None | 0.30817 | 0.96742 | ... | 0.40246 | 0.76937 | None | 3.387701 | 15.0 | NaN | NaN | None | NaN | 21.0 |
2 | 1 | 18.4 | 460 | None | None | 0.56310 | 0.72562 | None | 0.31071 | 0.96452 | ... | 0.40863 | 0.76542 | None | 3.442519 | 15.0 | NaN | NaN | None | NaN | 21.0 |
3 | 1 | 18.6 | 465 | None | None | 0.58031 | 0.73497 | None | 0.31365 | 0.96167 | ... | 0.41480 | 0.76085 | None | 3.514268 | 15.0 | NaN | NaN | None | NaN | 21.0 |
4 | 1 | 18.8 | 470 | None | None | 0.59753 | 0.74433 | None | 0.31705 | 0.95887 | ... | 0.42098 | 0.75571 | None | 3.601024 | 15.0 | NaN | NaN | None | NaN | 21.0 |
5 rows × 118 columns
Load local event files¶
In [5]:
Copied!
from kloppy import metrica
dataset = metrica.load_event(
event_data="../../kloppy/tests/files/metrica_events.json",
meta_data="../../kloppy/tests/files/epts_metrica_metadata.xml",
# Optional arguments
coordinates="metrica",
event_types=["shot", "pass"]
)
dataset.to_df().head()
from kloppy import metrica
dataset = metrica.load_event(
event_data="../../kloppy/tests/files/metrica_events.json",
meta_data="../../kloppy/tests/files/epts_metrica_metadata.xml",
# Optional arguments
coordinates="metrica",
event_types=["shot", "pass"]
)
dataset.to_df().head()
Out[5]:
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 | None | PASS | COMPLETE | True | 1 | 14.44 | 15.08 | alive | TEAM_A | TEAM_A | None | 0.50125 | 0.48725 | 0.49864 | 0.48705 | NaN | KICK_OFF | NaN |
1 | None | PASS | COMPLETE | True | 1 | 15.36 | 17.04 | alive | TEAM_A | TEAM_A | None | 0.49700 | 0.48500 | 0.63373 | 0.63449 | NaN | NaN | NaN |
2 | None | PASS | COMPLETE | True | 1 | 18.60 | 20.28 | alive | TEAM_A | TEAM_A | None | 0.66986 | 0.59707 | 0.80602 | 0.39821 | NaN | NaN | NaN |
3 | None | PASS | COMPLETE | True | 1 | 21.20 | 23.20 | alive | TEAM_A | TEAM_A | None | 0.80929 | 0.42922 | 0.79906 | 0.81522 | NaN | NaN | NaN |
4 | None | PASS | COMPLETE | True | 1 | 23.92 | 25.12 | alive | TEAM_A | TEAM_A | None | 0.79756 | 0.81998 | 0.68101 | 0.98059 | NaN | NaN | NaN |