Skip to content

Commit

Permalink
Merge pull request #350 from my-game-plan/feature/use-sample-wyscout-…
Browse files Browse the repository at this point in the history
…v3-data

[Wyscout v3] Use publicly available wyscout v3 event data
  • Loading branch information
koenvo authored Oct 28, 2024
2 parents a1aecfd + 7655813 commit 937726b
Show file tree
Hide file tree
Showing 3 changed files with 154,400 additions and 4,178 deletions.
30 changes: 19 additions & 11 deletions kloppy/infra/serializers/event/wyscout/deserializer_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,15 +593,24 @@ def deserialize(self, inputs: WyscoutInputs) -> EventDataset:
game_id = raw_events["events"][0].get("matchId")
if game_id:
game_id = str(game_id)
coaches = raw_events["coaches"]
if home_team_id in coaches and "coach" in coaches[home_team_id]:
home_coach = coaches[home_team_id]["coach"].get("shortName")
else:
home_coach = None
if away_team_id in coaches and "coach" in coaches[away_team_id]:
away_coach = coaches[away_team_id]["coach"].get("shortName")
else:
away_coach = None
home_coach = None
away_coach = None
coaches = raw_events.get("coaches")
if coaches:
if (
home_team_id in coaches
and "coach" in coaches[home_team_id]
):
home_coach = coaches[home_team_id]["coach"].get(
"shortName"
)
if (
away_team_id in coaches
and "coach" in coaches[away_team_id]
):
away_coach = coaches[away_team_id]["coach"].get(
"shortName"
)

events = []

Expand Down Expand Up @@ -633,8 +642,7 @@ def deserialize(self, inputs: WyscoutInputs) -> EventDataset:
if next_period_id != period_id:
periods[-1] = replace(
periods[-1],
end_timestamp=periods[-1].start_timestamp
+ timedelta(
end_timestamp=timedelta(
seconds=float(
raw_event["second"] + raw_event["minute"] * 60
)
Expand Down
Loading

0 comments on commit 937726b

Please sign in to comment.