Last active
March 14, 2020 04:29
-
-
Save databyjp/2b333e321b018d38bf20521dd4c1f02a 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
# Iterate every row of schedule: | |
for temp_tup in filt_sch_data.itertuples(): | |
home_tm_contacted = teams_contacted_df.loc[teams_contacted_df.team == temp_tup.home_team, 'contacted'] | |
away_tm_contacted = teams_contacted_df.loc[teams_contacted_df.team == temp_tup.away_team, 'contacted'] | |
if home_tm_contacted.values[0] != away_tm_contacted.values[0]: | |
home_away = [temp_tup.home_team, temp_tup.away_team] | |
for i in range(len(home_away)): | |
tm = home_away[i] | |
other_tm = home_away[1-i] | |
if teams_contacted_df.loc[teams_contacted_df.team == tm, 'date'].values[0] == None: | |
teams_contacted_df.loc[teams_contacted_df.team == tm, 'contacted'] = True | |
teams_contacted_df.loc[teams_contacted_df.team == tm, 'date'] = pd.to_datetime(temp_tup.est_time).date() | |
teams_contacted_df.loc[teams_contacted_df.team == tm, 'con_from'] = other_tm | |
other_tm_deg_sep = teams_contacted_df.loc[teams_contacted_df.team == other_tm, 'deg_sep'].values[0] | |
teams_contacted_df.loc[teams_contacted_df.team == tm, 'deg_sep'] = other_tm_deg_sep + 1 | |
teams_contacted_df.sort_values('date', inplace=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment