James McCool
commited on
Commit
·
54d06a1
1
Parent(s):
e53e33a
Enhance load_contest_file function to accept portfolio data for improved data integration
Browse files- Updated the load_contest_file function to include an optional portfolio parameter, allowing for better integration of portfolio data during contest file processing.
- Adjusted the logic in app.py to utilize the new portfolio parameter, ensuring that relevant portfolio information is incorporated into the contest data.
- This change improves data management and aligns with ongoing efforts to enhance user experience and data accessibility.
- app.py +1 -8
- global_func/load_contest_file.py +10 -1
app.py
CHANGED
|
@@ -190,14 +190,7 @@ with tab1:
|
|
| 190 |
|
| 191 |
|
| 192 |
if 'Contest_file' in st.session_state:
|
| 193 |
-
|
| 194 |
-
combined_df = pd.concat([st.session_state['Contest'], st.session_state['portfolio_df']], ignore_index=True)
|
| 195 |
-
combined_df = combined_df.reset_index(drop=True)
|
| 196 |
-
st.session_state['Contest'], st.session_state['ownership_df'], st.session_state['actual_df'], st.session_state['entry_list'], check_lineups = load_contest_file(combined_df, type_var, st.session_state['player_info'], sport_select)
|
| 197 |
-
else:
|
| 198 |
-
st.session_state['Contest'], st.session_state['ownership_df'], st.session_state['actual_df'], st.session_state['entry_list'], check_lineups = load_contest_file(st.session_state['Contest_file'], type_var, st.session_state['player_info'], sport_select)
|
| 199 |
-
st.session_state['Contest'] = st.session_state['Contest'].dropna(how='all')
|
| 200 |
-
st.session_state['Contest'] = st.session_state['Contest'].reset_index(drop=True)
|
| 201 |
st.session_state['Contest'] = st.session_state['Contest'].dropna(how='all')
|
| 202 |
st.session_state['Contest'] = st.session_state['Contest'].reset_index(drop=True)
|
| 203 |
if st.session_state['Contest'] is not None:
|
|
|
|
| 190 |
|
| 191 |
|
| 192 |
if 'Contest_file' in st.session_state:
|
| 193 |
+
st.session_state['Contest'], st.session_state['ownership_df'], st.session_state['actual_df'], st.session_state['entry_list'], check_lineups = load_contest_file(st.session_state['Contest_file'], type_var, st.session_state['player_info'], sport_select, st.session_state['portfolio_df'])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 194 |
st.session_state['Contest'] = st.session_state['Contest'].dropna(how='all')
|
| 195 |
st.session_state['Contest'] = st.session_state['Contest'].reset_index(drop=True)
|
| 196 |
if st.session_state['Contest'] is not None:
|
global_func/load_contest_file.py
CHANGED
|
@@ -3,7 +3,7 @@ import pandas as pd
|
|
| 3 |
from rapidfuzz import process, fuzz
|
| 4 |
from numpy import where as np_where
|
| 5 |
|
| 6 |
-
def load_contest_file(upload, type, helper = None, sport = None):
|
| 7 |
if upload is not None:
|
| 8 |
try:
|
| 9 |
try:
|
|
@@ -18,6 +18,8 @@ def load_contest_file(upload, type, helper = None, sport = None):
|
|
| 18 |
raw_df = upload
|
| 19 |
if helper is not None:
|
| 20 |
helper_df = helper
|
|
|
|
|
|
|
| 21 |
|
| 22 |
print('Made it through initial upload')
|
| 23 |
|
|
@@ -160,6 +162,13 @@ def load_contest_file(upload, type, helper = None, sport = None):
|
|
| 160 |
cleaned_df = cleaned_df[['BaseName', 'EntryCount', 'CPT', 'UTIL1', 'UTIL2', 'UTIL3', 'UTIL4', 'UTIL5']]
|
| 161 |
|
| 162 |
print('Made it through check_lineups')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
|
| 164 |
# Get unique entry names
|
| 165 |
entry_list = list(set(df['BaseName'].dropna()))
|
|
|
|
| 3 |
from rapidfuzz import process, fuzz
|
| 4 |
from numpy import where as np_where
|
| 5 |
|
| 6 |
+
def load_contest_file(upload, type, helper = None, sport = None, portfolio = None):
|
| 7 |
if upload is not None:
|
| 8 |
try:
|
| 9 |
try:
|
|
|
|
| 18 |
raw_df = upload
|
| 19 |
if helper is not None:
|
| 20 |
helper_df = helper
|
| 21 |
+
if portfolio is not None:
|
| 22 |
+
portfolio_df = portfolio
|
| 23 |
|
| 24 |
print('Made it through initial upload')
|
| 25 |
|
|
|
|
| 162 |
cleaned_df = cleaned_df[['BaseName', 'EntryCount', 'CPT', 'UTIL1', 'UTIL2', 'UTIL3', 'UTIL4', 'UTIL5']]
|
| 163 |
|
| 164 |
print('Made it through check_lineups')
|
| 165 |
+
|
| 166 |
+
if portfolio is not None:
|
| 167 |
+
portfolio_df['BaseName'] = 'Backtesting_upload'
|
| 168 |
+
portfolio_df['EntryCount'] = len(portfolio_df)
|
| 169 |
+
original_columns = cleaned_df.columns.tolist()
|
| 170 |
+
portfolio_df = portfolio_df[original_columns]
|
| 171 |
+
cleaned_df = pd.concat([cleaned_df, portfolio_df], ignore_index=True)
|
| 172 |
|
| 173 |
# Get unique entry names
|
| 174 |
entry_list = list(set(df['BaseName'].dropna()))
|