James McCool
commited on
Commit
·
a692d2e
1
Parent(s):
60d75d2
Refactor layout and improve contest file handling in app.py
Browse files- Adjusted column proportions in the Data Load tab for better UI layout.
- Moved the Contest File subheader to the correct column for improved organization.
- Streamlined the contest file loading logic, ensuring consistent handling of session state and enhancing user feedback upon successful file loading.
- Maintained existing functionality while improving code clarity and user experience.
- app.py +18 -17
- global_func/load_contest_file.py +0 -6
app.py
CHANGED
@@ -48,7 +48,7 @@ player_exposure_format = {'Exposure Overall': '{:.2%}', 'Exposure Top 1%': '{:.2
|
|
48 |
|
49 |
tab1, tab2 = st.tabs(["Data Load", "Contest Analysis"])
|
50 |
with tab1:
|
51 |
-
col1, col2 = st.columns(2)
|
52 |
|
53 |
with col1:
|
54 |
if st.button('Clear data', key='reset1'):
|
@@ -69,9 +69,7 @@ with tab1:
|
|
69 |
date_select = date_select.replace('-', '')
|
70 |
with game_options:
|
71 |
type_var = st.selectbox("Select Game Type", ['Classic', 'Showdown'], key='type_var')
|
72 |
-
|
73 |
-
with col2:
|
74 |
-
st.subheader("Contest File")
|
75 |
if parse_type == 'DB Search':
|
76 |
if 'Contest_file_helper' in st.session_state:
|
77 |
del st.session_state['Contest_file_helper']
|
@@ -83,7 +81,10 @@ with tab1:
|
|
83 |
st.session_state['Contest_file'] = grab_contest_data(sport_select, contest_name_var, contest_id_map, date_select)
|
84 |
else:
|
85 |
pass
|
86 |
-
|
|
|
|
|
|
|
87 |
if 'Contest_file_helper' in st.session_state:
|
88 |
del st.session_state['Contest_file_helper']
|
89 |
if 'Contest_file' in st.session_state:
|
@@ -95,18 +96,18 @@ with tab1:
|
|
95 |
else:
|
96 |
pass
|
97 |
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
|
111 |
if 'Contest_file' in st.session_state:
|
112 |
st.session_state['ownership_dict'] = dict(zip(st.session_state['ownership_df']['Player'], st.session_state['ownership_df']['Own']))
|
|
|
48 |
|
49 |
tab1, tab2 = st.tabs(["Data Load", "Contest Analysis"])
|
50 |
with tab1:
|
51 |
+
col1, col2 = st.columns([2, 8])
|
52 |
|
53 |
with col1:
|
54 |
if st.button('Clear data', key='reset1'):
|
|
|
69 |
date_select = date_select.replace('-', '')
|
70 |
with game_options:
|
71 |
type_var = st.selectbox("Select Game Type", ['Classic', 'Showdown'], key='type_var')
|
72 |
+
|
|
|
|
|
73 |
if parse_type == 'DB Search':
|
74 |
if 'Contest_file_helper' in st.session_state:
|
75 |
del st.session_state['Contest_file_helper']
|
|
|
81 |
st.session_state['Contest_file'] = grab_contest_data(sport_select, contest_name_var, contest_id_map, date_select)
|
82 |
else:
|
83 |
pass
|
84 |
+
with col2:
|
85 |
+
st.subheader("Contest File")
|
86 |
+
|
87 |
+
if parse_type == 'Manual':
|
88 |
if 'Contest_file_helper' in st.session_state:
|
89 |
del st.session_state['Contest_file_helper']
|
90 |
if 'Contest_file' in st.session_state:
|
|
|
96 |
else:
|
97 |
pass
|
98 |
|
99 |
+
if 'Contest_file' in st.session_state:
|
100 |
+
if 'Contest_file_helper' in st.session_state:
|
101 |
+
st.table(st.session_state['Contest_file'].head(10))
|
102 |
+
st.session_state['Contest'], st.session_state['ownership_df'], st.session_state['actual_df'], st.session_state['salary_df'], st.session_state['team_df'], st.session_state['pos_df'], st.session_state['entry_list'], check_lineups = load_contest_file(st.session_state['Contest_file'], st.session_state['Contest_file_helper'], sport_select)
|
103 |
+
else:
|
104 |
+
st.table(st.session_state['Contest_file'].head(10))
|
105 |
+
st.session_state['Contest'], st.session_state['ownership_df'], st.session_state['actual_df'], st.session_state['salary_df'], st.session_state['team_df'], st.session_state['pos_df'], st.session_state['entry_list'], check_lineups = load_contest_file(st.session_state['Contest_file'], None, sport_select)
|
106 |
+
st.session_state['Contest'] = st.session_state['Contest'].dropna(how='all')
|
107 |
+
st.session_state['Contest'] = st.session_state['Contest'].reset_index(drop=True)
|
108 |
+
if st.session_state['Contest'] is not None:
|
109 |
+
st.success('Contest file loaded successfully!')
|
110 |
+
st.dataframe(st.session_state['Contest'].head(100))
|
111 |
|
112 |
if 'Contest_file' in st.session_state:
|
113 |
st.session_state['ownership_dict'] = dict(zip(st.session_state['ownership_df']['Player'], st.session_state['ownership_df']['Own']))
|
global_func/load_contest_file.py
CHANGED
@@ -3,12 +3,6 @@ import pandas as pd
|
|
3 |
from rapidfuzz import process, fuzz
|
4 |
|
5 |
def load_contest_file(upload, helper = None, sport = None):
|
6 |
-
if sport == 'MLB':
|
7 |
-
pos_list = [' P ', ' C ', '1B ', ' 2B ', ' 3B ', ' SS ', ' OF ']
|
8 |
-
elif sport == 'MMA':
|
9 |
-
pos_list = [' P ', ' C ', '1B ', ' 2B ', ' 3B ', ' SS ', ' OF ']
|
10 |
-
elif sport == 'GOLF':
|
11 |
-
pos_list = [' P ', ' C ', '1B ', ' 2B ', ' 3B ', ' SS ', ' OF ']
|
12 |
if upload is not None:
|
13 |
try:
|
14 |
try:
|
|
|
3 |
from rapidfuzz import process, fuzz
|
4 |
|
5 |
def load_contest_file(upload, helper = None, sport = None):
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
if upload is not None:
|
7 |
try:
|
8 |
try:
|