Created
January 13, 2021 08:39
-
-
Save databyjp/3c7870ff8bc74230e5d9fd66d06e9e3a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# ===== Group dataframe by player & game | |
players = shots_df.groupby("player").count()["date"].sort_values()[-200:].index | |
pl_df = shots_df[shots_df.player.isin(players)] | |
grp_pl_df = pl_df.groupby(["player", "date"]).shot_made.sum().reset_index() | |
grp_pl_df = grp_pl_df.assign(shot_count=pl_df.groupby(["player", "date"]).shot_made.count().values) | |
grp_pl_df = grp_pl_df.assign(shot_acc=grp_pl_df["shot_made"]/grp_pl_df["shot_count"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment