def players_assists(events): goals = evfilter.goals(events) players_assists = pd.melt(goals[['ev.player.2','ev.player.3']]).dropna().groupby('value').size() players_assists.index.name = 'player' return players_assists
def goals_against(events): "Aggregate goals against for individual goalies over the input set of events. Returns a series indexed by goalie text_id." goals = evfilter.goals(events) goalies = pd.Series(data=goals["home.G"], index=goals.index) goalies[goals["ev.team"] == goals["hometeam"]] = goals["away.G"] return goalies.dropna().value_counts().sort_index()
def players_goals(events): goals = evfilter.goals(events) players_goals = goals.groupby('ev.player.1').size() players_goals.index.name = 'player' return players_goals