Update app.py
Browse files
app.py
CHANGED
@@ -6,6 +6,8 @@ import seaborn as sns
|
|
6 |
from datetime import date, timedelta
|
7 |
import random
|
8 |
|
|
|
|
|
9 |
# [All the scheduling functions and analytics functions here]
|
10 |
|
11 |
|
@@ -61,8 +63,8 @@ def assign_dates_to_matches(matches):
|
|
61 |
return [(match[0], match[1], extended_dates[i]) for i, match in enumerate(matches)]
|
62 |
|
63 |
|
64 |
-
# 6.
|
65 |
-
def
|
66 |
full_schedule = []
|
67 |
for i in range(num_conferences):
|
68 |
conference_name = chr(65 + i)
|
@@ -165,10 +167,18 @@ def commissioner_analytics(schedule_df, commissioners):
|
|
165 |
|
166 |
st.title("Basketball Game Schedule Generator")
|
167 |
|
168 |
-
# Initialize session state for schedule_df
|
169 |
if 'schedule_df' not in st.session_state:
|
170 |
st.session_state.schedule_df = None
|
171 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
172 |
# Configuration UI
|
173 |
st.header("Configuration")
|
174 |
|
@@ -200,29 +210,29 @@ if st.session_state.schedule_df is not None:
|
|
200 |
# Analytics & Comparisons
|
201 |
st.header("Analytics & Comparisons")
|
202 |
analytics_option = st.selectbox("Choose an analysis type:", ["Team Workload Analysis", "Match Distribution", "Inter-Conference Match Analysis", "Commissioner Analytics"])
|
203 |
-
historical_data['Date'] = pd.to_datetime(historical_data['Date'])
|
204 |
|
205 |
if analytics_option == "Team Workload Analysis":
|
206 |
st.subheader("Historical Data")
|
207 |
-
st.pyplot(team_workload_analysis(historical_data))
|
208 |
st.subheader("Current Data")
|
209 |
st.pyplot(team_workload_analysis(st.session_state.schedule_df))
|
210 |
|
211 |
elif analytics_option == "Match Distribution":
|
212 |
st.subheader("Historical Data")
|
213 |
-
st.pyplot(match_distribution(historical_data))
|
214 |
st.subheader("Current Data")
|
215 |
st.pyplot(match_distribution(st.session_state.schedule_df))
|
216 |
|
217 |
elif analytics_option == "Inter-Conference Match Analysis":
|
218 |
st.subheader("Historical Data")
|
219 |
-
st.pyplot(inter_conference_analysis(historical_data))
|
220 |
st.subheader("Current Data")
|
221 |
st.pyplot(inter_conference_analysis(st.session_state.schedule_df))
|
222 |
|
223 |
elif analytics_option == "Commissioner Analytics":
|
224 |
st.subheader("Historical Data")
|
225 |
-
st.pyplot(commissioner_analytics(historical_data, commissioners))
|
226 |
st.subheader("Current Data")
|
227 |
st.pyplot(commissioner_analytics(st.session_state.schedule_df, commissioners))
|
228 |
|
|
|
6 |
from datetime import date, timedelta
|
7 |
import random
|
8 |
|
9 |
+
|
10 |
+
|
11 |
# [All the scheduling functions and analytics functions here]
|
12 |
|
13 |
|
|
|
63 |
return [(match[0], match[1], extended_dates[i]) for i, match in enumerate(matches)]
|
64 |
|
65 |
|
66 |
+
# 6. generate_mock_st.session_state.historical_data
|
67 |
+
def generate_mock_st.session_state.historical_data(num_teams, num_conferences, num_inter_games, start_date, end_date):
|
68 |
full_schedule = []
|
69 |
for i in range(num_conferences):
|
70 |
conference_name = chr(65 + i)
|
|
|
167 |
|
168 |
st.title("Basketball Game Schedule Generator")
|
169 |
|
170 |
+
# Initialize session state for schedule_df and st.session_state.historical_data
|
171 |
if 'schedule_df' not in st.session_state:
|
172 |
st.session_state.schedule_df = None
|
173 |
|
174 |
+
if 'st.session_state.historical_data' not in st.session_state:
|
175 |
+
st.session_state.st.session_state.historical_data = None
|
176 |
+
|
177 |
+
if st.session_state.st.session_state.historical_data is None:
|
178 |
+
st.session_state.st.session_state.historical_data = generate_mock_st.session_state.historical_data(num_teams, num_conferences, num_inter_games, date(2022, 11, 6), date(2023, 3, 1))
|
179 |
+
st.session_state.st.session_state.historical_data['Date'] = pd.to_datetime(st.session_state.st.session_state.historical_data['Date'])
|
180 |
+
|
181 |
+
|
182 |
# Configuration UI
|
183 |
st.header("Configuration")
|
184 |
|
|
|
210 |
# Analytics & Comparisons
|
211 |
st.header("Analytics & Comparisons")
|
212 |
analytics_option = st.selectbox("Choose an analysis type:", ["Team Workload Analysis", "Match Distribution", "Inter-Conference Match Analysis", "Commissioner Analytics"])
|
213 |
+
st.session_state.historical_data['Date'] = pd.to_datetime(st.session_state.historical_data['Date'])
|
214 |
|
215 |
if analytics_option == "Team Workload Analysis":
|
216 |
st.subheader("Historical Data")
|
217 |
+
st.pyplot(team_workload_analysis(st.session_state.historical_data))
|
218 |
st.subheader("Current Data")
|
219 |
st.pyplot(team_workload_analysis(st.session_state.schedule_df))
|
220 |
|
221 |
elif analytics_option == "Match Distribution":
|
222 |
st.subheader("Historical Data")
|
223 |
+
st.pyplot(match_distribution(st.session_state.historical_data))
|
224 |
st.subheader("Current Data")
|
225 |
st.pyplot(match_distribution(st.session_state.schedule_df))
|
226 |
|
227 |
elif analytics_option == "Inter-Conference Match Analysis":
|
228 |
st.subheader("Historical Data")
|
229 |
+
st.pyplot(inter_conference_analysis(st.session_state.historical_data))
|
230 |
st.subheader("Current Data")
|
231 |
st.pyplot(inter_conference_analysis(st.session_state.schedule_df))
|
232 |
|
233 |
elif analytics_option == "Commissioner Analytics":
|
234 |
st.subheader("Historical Data")
|
235 |
+
st.pyplot(commissioner_analytics(st.session_state.historical_data, commissioners))
|
236 |
st.subheader("Current Data")
|
237 |
st.pyplot(commissioner_analytics(st.session_state.schedule_df, commissioners))
|
238 |
|