Skip to content

Instantly share code, notes, and snippets.

@databyjp
Created March 17, 2022 12:09
Show Gist options
  • Select an option

  • Save databyjp/9fbfbdda9a36351692bf9ba9a3a5c252 to your computer and use it in GitHub Desktop.

Select an option

Save databyjp/9fbfbdda9a36351692bf9ba9a3a5c252 to your computer and use it in GitHub Desktop.
gdf = shots_df.groupby("shot_zone").agg({"shot_made": "sum", "period": "count"})
gdf = gdf.reset_index().rename({"period": "shot_atts"}, axis=1)
gdf = gdf.assign(team="NBA")
gdf = gdf.assign(shot_freq=gdf.shot_atts / gdf.shot_atts.sum())
gdf = gdf.assign(shot_acc=gdf.shot_made / gdf.shot_atts)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment