Skip to content

Commit 58ad3c2

Browse files
committed
fix(spadl): do not insert synthetic dribbles before headed shots
This makes sure that no dribbles are inserted before headed shots.
1 parent a6c8155 commit 58ad3c2

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

socceraction/spadl/base.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ def _add_dribbles(actions: pd.DataFrame) -> pd.DataFrame:
4242
not_offensive_foul = same_team & (
4343
next_actions.type_id != spadlconfig.actiontypes.index('foul')
4444
)
45+
not_headed_shot = (next_actions.type_id != spadlconfig.actiontypes.index('shot')) & (
46+
next_actions.bodypart_id != spadlconfig.bodyparts.index('head')
47+
)
4548

4649
dx = actions.end_x - next_actions.start_x
4750
dy = actions.end_y - next_actions.start_y
@@ -53,7 +56,13 @@ def _add_dribbles(actions: pd.DataFrame) -> pd.DataFrame:
5356
same_period = actions.period_id == next_actions.period_id
5457

5558
dribble_idx = (
56-
same_team & far_enough & not_too_far & same_phase & same_period & not_offensive_foul
59+
same_team
60+
& far_enough
61+
& not_too_far
62+
& same_phase
63+
& same_period
64+
& not_offensive_foul
65+
& not_headed_shot
5766
)
5867

5968
dribbles = pd.DataFrame()

0 commit comments

Comments
 (0)