Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -67,10 +67,13 @@ def init_baslines():
|
|
67 |
raw_display.rename(columns={"name": "Player"}, inplace = True)
|
68 |
fd_ids = dict(zip(raw_display['Player'], raw_display['player_id']))
|
69 |
|
70 |
-
|
|
|
71 |
|
72 |
-
dk_roo_raw, fd_roo_raw,
|
73 |
-
|
|
|
|
|
74 |
|
75 |
static_exposure = pd.DataFrame(columns=['Player', 'count'])
|
76 |
overall_exposure = pd.DataFrame(columns=['Player', 'count'])
|
@@ -430,6 +433,7 @@ def get_uncorrelated_portfolio_for_sim(Total_Sample_Size, sharp_split, field_gro
|
|
430 |
tab1, tab2 = st.tabs(['Uploads', 'Contest Sim'])
|
431 |
|
432 |
with tab1:
|
|
|
433 |
with st.container():
|
434 |
col1, col2 = st.columns([3, 3])
|
435 |
|
@@ -616,8 +620,8 @@ with tab2:
|
|
616 |
st.cache_data.clear()
|
617 |
for key in st.session_state.keys():
|
618 |
del st.session_state[key]
|
619 |
-
dk_roo_raw, fd_roo_raw, dkid_dict, fdid_dict = init_baslines()
|
620 |
-
t_stamp = f"Last Update: " +
|
621 |
|
622 |
slate_var1 = st.radio("Which data are you loading?", ('Main Slate', 'User'))
|
623 |
site_var1 = st.radio("What site are you working with?", ('Draftkings', 'Fanduel'))
|
@@ -701,7 +705,7 @@ with tab2:
|
|
701 |
# # Apply the calculation to the DataFrame
|
702 |
# initial_proj['Own%'] = initial_proj.apply(lambda row: calculate_own(row['Position'], row['Own'], initial_proj.loc[initial_proj['Position'] == row['Position'], 'Own'].mean(), factor_c if row['Position'] == 'C' else factor_other), axis=1)
|
703 |
# initial_proj['Own%'] = initial_proj['Own%'].clip(upper=85)
|
704 |
-
initial_proj['Own'] = initial_proj['Own
|
705 |
|
706 |
# Drop unnecessary columns and create the final DataFrame
|
707 |
Overall_Proj = initial_proj[['Player', 'Team', 'Position', 'Median', 'Own', 'Salary']]
|
@@ -737,6 +741,8 @@ with tab2:
|
|
737 |
UserPortfolio = pd.DataFrame(columns = ['PG', 'SG', 'SF', 'PF', 'C', 'G', 'F', 'UTIL'])
|
738 |
|
739 |
Overall_Proj.replace('', np.nan, inplace=True)
|
|
|
|
|
740 |
Overall_Proj = Overall_Proj.dropna(subset=['Median'])
|
741 |
Overall_Proj = Overall_Proj.assign(Value=lambda x: (x.Median / (x.Salary / 1000)))
|
742 |
Overall_Proj['Sort_var'] = (Overall_Proj['Median'].rank(ascending=False) + Overall_Proj['Value'].rank(ascending=False)) / 2
|
|
|
67 |
raw_display.rename(columns={"name": "Player"}, inplace = True)
|
68 |
fd_ids = dict(zip(raw_display['Player'], raw_display['player_id']))
|
69 |
|
70 |
+
worksheet = sh.worksheet('Timestamp')
|
71 |
+
timestamp = worksheet.acell('A1').value
|
72 |
|
73 |
+
return dk_roo_raw, fd_roo_raw, dk_ids, fd_ids, timestamp
|
74 |
+
|
75 |
+
dk_roo_raw, fd_roo_raw, dkid_dict, fdid_dict, timestamp = init_baslines()
|
76 |
+
t_stamp = f"Last Update: " + str(timestamp) + f" CST"
|
77 |
|
78 |
static_exposure = pd.DataFrame(columns=['Player', 'count'])
|
79 |
overall_exposure = pd.DataFrame(columns=['Player', 'count'])
|
|
|
433 |
tab1, tab2 = st.tabs(['Uploads', 'Contest Sim'])
|
434 |
|
435 |
with tab1:
|
436 |
+
st.info("The contest sim currently only works for Draftkings, the roster formation for Fanduel is incorrect. It'll be fixed in the next couple of days!")
|
437 |
with st.container():
|
438 |
col1, col2 = st.columns([3, 3])
|
439 |
|
|
|
620 |
st.cache_data.clear()
|
621 |
for key in st.session_state.keys():
|
622 |
del st.session_state[key]
|
623 |
+
dk_roo_raw, fd_roo_raw, dkid_dict, fdid_dict, timestamp = init_baslines()
|
624 |
+
t_stamp = f"Last Update: " + str(timestamp) + f" CST"
|
625 |
|
626 |
slate_var1 = st.radio("Which data are you loading?", ('Main Slate', 'User'))
|
627 |
site_var1 = st.radio("What site are you working with?", ('Draftkings', 'Fanduel'))
|
|
|
705 |
# # Apply the calculation to the DataFrame
|
706 |
# initial_proj['Own%'] = initial_proj.apply(lambda row: calculate_own(row['Position'], row['Own'], initial_proj.loc[initial_proj['Position'] == row['Position'], 'Own'].mean(), factor_c if row['Position'] == 'C' else factor_other), axis=1)
|
707 |
# initial_proj['Own%'] = initial_proj['Own%'].clip(upper=85)
|
708 |
+
initial_proj['Own'] = initial_proj['Own'] * (900 / initial_proj['Own'].sum())
|
709 |
|
710 |
# Drop unnecessary columns and create the final DataFrame
|
711 |
Overall_Proj = initial_proj[['Player', 'Team', 'Position', 'Median', 'Own', 'Salary']]
|
|
|
741 |
UserPortfolio = pd.DataFrame(columns = ['PG', 'SG', 'SF', 'PF', 'C', 'G', 'F', 'UTIL'])
|
742 |
|
743 |
Overall_Proj.replace('', np.nan, inplace=True)
|
744 |
+
Overall_Proj = Overall_Proj.replace(',','', regex=True)
|
745 |
+
Overall_Proj['Salary'] = Overall_Proj['Salary'].astype(int)
|
746 |
Overall_Proj = Overall_Proj.dropna(subset=['Median'])
|
747 |
Overall_Proj = Overall_Proj.assign(Value=lambda x: (x.Median / (x.Salary / 1000)))
|
748 |
Overall_Proj['Sort_var'] = (Overall_Proj['Median'].rank(ascending=False) + Overall_Proj['Value'].rank(ascending=False)) / 2
|