-
-
Save lmiller1990/4a0a7b714f3394fdde5cbc09d2eecebd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def opponent_games(df, team, gameids): | |
""" | |
Returns opponents for a given team. | |
Arguments: | |
df: the dataframe containing the data. | |
team: the team you are interested in. | |
games: a array of gameids the team played in. | |
""" | |
games = df[df.gameid.isin(gameids)] | |
opponent_games = games[games.team != team].drop_duplicates(subset=['gameid'])[['gameid', 'team']] | |
opponent_games.columns = ['gameid', 'opponent'] | |
return opponent_games |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment