Last active
February 21, 2020 00:59
-
-
Save databyjp/e487995b6aa6c79452cdcddb5a3ffe4c 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
temp_df_list = list() | |
temp_slugs = season_tot_df[season_tot_df['name'].isin(['James Harden', 'Chris Paul'])].slug.unique() | |
for pl_slug in temp_slugs: | |
temp_df = pd.DataFrame(pl_data_dict[pl_slug]) | |
temp_df = add_fan_pts(temp_df) | |
temp_df = temp_df.assign(player=season_tot_df[season_tot_df.slug == pl_slug]['name'].values[0]) | |
temp_df_list.append(temp_df) | |
comp_df = pd.concat(temp_df_list, axis=0) | |
comp_df.reset_index(inplace=True, drop=True) | |
dates_grp = comp_df.groupby('date').count() | |
dates_both_played = dates_grp[dates_grp['team'] == 2].index | |
# comb_dates_df = comp_df[comp_df.date.isin(dates_both_played)] | |
comb_dates_list = list() | |
for temp_date in dates_both_played: | |
jh_points = comp_df[(comp_df.date == temp_date) & (comp_df.player == 'James Harden')].fan_pts.values[0] | |
cp_points = comp_df[(comp_df.date == temp_date) & (comp_df.player == 'Chris Paul')].fan_pts.values[0] | |
temp_dict = dict( | |
date=temp_date, | |
Harden=jh_points, | |
Paul=cp_points, | |
Sum=jh_points+cp_points, | |
) | |
comb_dates_list.append(temp_dict) | |
comb_dates_df = pd.DataFrame(comb_dates_list) | |
fig = px.scatter(comb_dates_df, x='Harden', y='Paul', color='Sum', range_color=[40, 125], range_y=[8, 55]) | |
clean_chart_format(fig, namelocs=[0.1, 0.9]) | |
fig.update_layout(title='Fantasy performance comparison') | |
fig.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment