Skip to content

Commit

Permalink
Avoid duplicate players in additions email
Browse files Browse the repository at this point in the history
  • Loading branch information
peteb206 authored Jan 6, 2025
1 parent f7ac90b commit 195423c
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions scrape.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ def email_additions(to: str):
players_df = players_df[players_df['added'].apply(lambda x: (datetime.today() - datetime.strptime(x, "%Y-%m-%d")).days) < 4] # Players added this week
added_players_df = pd.concat([added_players_df, players_df], ignore_index = True)
added_players_df = added_players_df.rename({'school': 'stats_url'}, axis = 1).merge(schools_df, how = 'left', on = 'stats_url').sort_values(by = 'last_name')
added_players_df.drop_duplicates(subset = ['roster_url', 'last_name', 'first_name'], inplace = True) # keep first (highest league for a school)
email_html = cbn_utils.player_scrape_results_email_html(added_players_df)
cbn_utils.send_email(to, f'New Players (Week of {datetime.now().strftime("%B %d, %Y")})', email_html)

Expand Down

0 comments on commit 195423c

Please sign in to comment.