In [1]:
Copied!
from kloppy import skillcorner
dataset = skillcorner.load(
meta_data="../../kloppy/tests/files/skillcorner_match_data.json",
raw_data="../../kloppy/tests/files/skillcorner_structured_data.json",
# Optional arguments
sample_rate=1/10,
limit=100,
coordinates="skillcorner",
include_empty_frames=False
)
dataset.to_df().head()
from kloppy import skillcorner
dataset = skillcorner.load(
meta_data="../../kloppy/tests/files/skillcorner_match_data.json",
raw_data="../../kloppy/tests/files/skillcorner_structured_data.json",
# Optional arguments
sample_rate=1/10,
limit=100,
coordinates="skillcorner",
include_empty_frames=False
)
dataset.to_df().head()
Out[1]:
period_id | timestamp | frame_id | ball_state | ball_owning_team_id | ball_x | ball_y | ball_z | home_22_x | home_22_y | ... | away_anon_304_d | away_anon_304_s | home_anon_368_x | home_anon_368_y | home_anon_368_d | home_anon_368_s | home_anon_423_x | home_anon_423_y | home_anon_423_d | home_anon_423_s | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1 | 12.0 | 1531 | None | NaN | 18.887029 | 30.037350 | 1.246213 | 14.195641 | 23.489013 | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
1 | 1 | 13.0 | 1541 | None | NaN | 13.514701 | 25.827027 | 0.657040 | 14.230466 | 15.453939 | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
2 | 1 | 14.0 | 1551 | None | NaN | 16.835040 | 27.427233 | 0.057516 | 15.328696 | 17.867260 | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
3 | 1 | 15.0 | 1561 | None | NaN | 11.656880 | 24.721404 | NaN | 13.642248 | 22.210971 | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
4 | 1 | 16.0 | 1571 | None | 103.0 | 7.426918 | 30.572856 | NaN | NaN | NaN | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
5 rows × 140 columns
Load remote open data files¶
SkillCorner has available a selection of 9 games available on their GitHub, listed below are these games and their respective match_ids.
match_id | home_team | away_team | date_time |
---|---|---|---|
4039 | Manchester City | Liverpool | 2020-07-02 |
3749 | Dortmund | Bayern Munchen | 2020-05-26 |
3518 | Juventus | Inter | 2020-03-08 |
3442 | Real Madrid | FC Barcelona | 2020-03-01 |
2841 | FC Barcelona | Real Madrid | 2019-12-18 |
2440 | Liverpool | Manchester City | 2019-11-10 |
2417 | Bayern Munchen | Dortmund | 2019-11-09 |
2269 | Paris | Marseille | 2019-10-27 |
2068 | Inter | Juventus | 2019-10-06 |
In [2]:
Copied!
from kloppy import skillcorner
dataset = skillcorner.load(
meta_data="https://raw.githubusercontent.com/SkillCorner/opendata/master/data/matches/4039/match_data.json",
raw_data="https://raw.githubusercontent.com/SkillCorner/opendata/master/data/matches/4039/structured_data.json",
# Optional arguments
sample_rate=1/10,
limit=100,
coordinates="skillcorner",
include_empty_frames=False
)
dataset.to_df().head()
from kloppy import skillcorner
dataset = skillcorner.load(
meta_data="https://raw.githubusercontent.com/SkillCorner/opendata/master/data/matches/4039/match_data.json",
raw_data="https://raw.githubusercontent.com/SkillCorner/opendata/master/data/matches/4039/structured_data.json",
# Optional arguments
sample_rate=1/10,
limit=100,
coordinates="skillcorner",
include_empty_frames=False
)
dataset.to_df().head()
Out[2]:
period_id | timestamp | frame_id | ball_state | ball_owning_team_id | ball_x | ball_y | ball_z | home_47_x | home_47_y | ... | home_31_d | home_31_s | home_anon_471_x | home_anon_471_y | home_anon_471_d | home_anon_471_s | home_anon_501_x | home_anon_501_y | home_anon_501_d | home_anon_501_s | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1 | 1.0 | 452 | None | NaN | 14.693770 | -0.907936 | 5.222056e-02 | -4.630710 | -20.740084 | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
1 | 1 | 2.0 | 462 | None | NaN | 14.634828 | -0.030155 | -3.604550e-02 | NaN | NaN | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
2 | 1 | 13.0 | 572 | None | 40.0 | 37.410470 | -19.993496 | -7.256100e-16 | 19.580474 | -19.368974 | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
3 | 1 | 14.0 | 582 | None | 40.0 | 42.215165 | -22.637840 | 1.230652e-01 | 26.785449 | -18.257435 | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
4 | 1 | 15.0 | 592 | None | 40.0 | 42.433060 | -28.680917 | NaN | 31.769383 | -22.166959 | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
5 rows × 112 columns
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://.../skillcorner_match_data.jsonl
)
Note: Kloppy might throw an the first time to help you identify missing cloud specific dependencies like s3fs
.
In [ ]:
Copied!
from kloppy import skillcorner
dataset = skillcorner.load_open_data(
meta_data="s3://.../skillcorner_match_data.jsonl",
raw_data="s3://.../skillcorner_structured_data.json",
# Optional arguments
sample_rate=1/10,
limit=100,
coordinates="skillcorner",
include_empty_frames=False
)
dataset.to_df().head()
from kloppy import skillcorner
dataset = skillcorner.load_open_data(
meta_data="s3://.../skillcorner_match_data.jsonl",
raw_data="s3://.../skillcorner_structured_data.json",
# Optional arguments
sample_rate=1/10,
limit=100,
coordinates="skillcorner",
include_empty_frames=False
)
dataset.to_df().head()
Out[ ]:
period_id | timestamp | frame_id | ball_state | ball_owning_team_id | ball_x | ball_y | ball_z | home_47_x | home_47_y | ... | home_31_d | home_31_s | home_anon_471_x | home_anon_471_y | home_anon_471_d | home_anon_471_s | home_anon_501_x | home_anon_501_y | home_anon_501_d | home_anon_501_s | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1 | 1.0 | 452 | None | NaN | 14.693770 | -0.907936 | 5.222056e-02 | -4.630710 | -20.740084 | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
1 | 1 | 2.0 | 462 | None | NaN | 14.634828 | -0.030155 | -3.604550e-02 | NaN | NaN | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
2 | 1 | 13.0 | 572 | None | 40.0 | 37.410470 | -19.993496 | -7.256100e-16 | 19.580474 | -19.368974 | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
3 | 1 | 14.0 | 582 | None | 40.0 | 42.215165 | -22.637840 | 1.230652e-01 | 26.785449 | -18.257435 | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
4 | 1 | 15.0 | 592 | None | 40.0 | 42.433060 | -28.680917 | NaN | 31.769383 | -22.166959 | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
5 rows × 112 columns