Update app.py
Browse files
app.py
CHANGED
@@ -82,9 +82,16 @@ def generate_mock_historical_data(num_teams, num_conferences, num_inter_games, s
|
|
82 |
|
83 |
# Team Workload Analysis
|
84 |
def team_workload_analysis(schedule_df):
|
|
|
85 |
if schedule_df is None:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
return
|
87 |
-
else
|
88 |
"""Generate a bar chart showing the number of matches each team has per week."""
|
89 |
schedule_df['Week'] = schedule_df['Date'].dt.isocalendar().week
|
90 |
team_counts = schedule_df.groupby(['Week', 'Team 1']).size().unstack().fillna(0)
|
@@ -100,9 +107,16 @@ def team_workload_analysis(schedule_df):
|
|
100 |
|
101 |
# Match Distribution
|
102 |
def match_distribution(schedule_df):
|
|
|
103 |
if schedule_df is None:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
return
|
105 |
-
else
|
106 |
"""Generate a histogram showing match distribution across months."""
|
107 |
schedule_df['Month'] = schedule_df['Date'].dt.month_name()
|
108 |
month_order = ['November', 'December', 'January', 'February', 'March']
|
@@ -118,9 +132,16 @@ def match_distribution(schedule_df):
|
|
118 |
|
119 |
# Inter-Conference Match Analysis
|
120 |
def inter_conference_analysis(schedule_df):
|
|
|
121 |
if schedule_df is None:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
return
|
123 |
-
else
|
124 |
"""Generate a heatmap showing inter-conference match frequencies."""
|
125 |
# Extract the conference from the team names
|
126 |
schedule_df['Conference 1'] = schedule_df['Team 1'].str[0]
|
@@ -152,9 +173,16 @@ def inter_conference_analysis(schedule_df):
|
|
152 |
|
153 |
# Commissioner Analytics
|
154 |
def commissioner_analytics(schedule_df, commissioners):
|
|
|
155 |
if schedule_df is None:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
return
|
157 |
-
else
|
158 |
"""Generate a bar chart showing matches overseen by each commissioner."""
|
159 |
# Assuming each commissioner oversees a specific conference
|
160 |
comm_dict = {f"Conference {chr(65+i)}": comm for i, comm in enumerate(commissioners)}
|
|
|
82 |
|
83 |
# Team Workload Analysis
|
84 |
def team_workload_analysis(schedule_df):
|
85 |
+
# Check if the DataFrame is None
|
86 |
if schedule_df is None:
|
87 |
+
plt.figure(figsize=(10, 6))
|
88 |
+
plt.text(0.5, 0.5, 'Please generate the schedule first before viewing analytics.',
|
89 |
+
horizontalalignment='center', verticalalignment='center',
|
90 |
+
fontsize=14, color='red')
|
91 |
+
plt.axis('off')
|
92 |
+
plt.tight_layout()
|
93 |
+
plt.show()
|
94 |
return
|
|
|
95 |
"""Generate a bar chart showing the number of matches each team has per week."""
|
96 |
schedule_df['Week'] = schedule_df['Date'].dt.isocalendar().week
|
97 |
team_counts = schedule_df.groupby(['Week', 'Team 1']).size().unstack().fillna(0)
|
|
|
107 |
|
108 |
# Match Distribution
|
109 |
def match_distribution(schedule_df):
|
110 |
+
# Check if the DataFrame is None
|
111 |
if schedule_df is None:
|
112 |
+
plt.figure(figsize=(10, 6))
|
113 |
+
plt.text(0.5, 0.5, 'Please generate the schedule first before viewing analytics.',
|
114 |
+
horizontalalignment='center', verticalalignment='center',
|
115 |
+
fontsize=14, color='red')
|
116 |
+
plt.axis('off')
|
117 |
+
plt.tight_layout()
|
118 |
+
plt.show()
|
119 |
return
|
|
|
120 |
"""Generate a histogram showing match distribution across months."""
|
121 |
schedule_df['Month'] = schedule_df['Date'].dt.month_name()
|
122 |
month_order = ['November', 'December', 'January', 'February', 'March']
|
|
|
132 |
|
133 |
# Inter-Conference Match Analysis
|
134 |
def inter_conference_analysis(schedule_df):
|
135 |
+
# Check if the DataFrame is None
|
136 |
if schedule_df is None:
|
137 |
+
plt.figure(figsize=(10, 6))
|
138 |
+
plt.text(0.5, 0.5, 'Please generate the schedule first before viewing analytics.',
|
139 |
+
horizontalalignment='center', verticalalignment='center',
|
140 |
+
fontsize=14, color='red')
|
141 |
+
plt.axis('off')
|
142 |
+
plt.tight_layout()
|
143 |
+
plt.show()
|
144 |
return
|
|
|
145 |
"""Generate a heatmap showing inter-conference match frequencies."""
|
146 |
# Extract the conference from the team names
|
147 |
schedule_df['Conference 1'] = schedule_df['Team 1'].str[0]
|
|
|
173 |
|
174 |
# Commissioner Analytics
|
175 |
def commissioner_analytics(schedule_df, commissioners):
|
176 |
+
# Check if the DataFrame is None
|
177 |
if schedule_df is None:
|
178 |
+
plt.figure(figsize=(10, 6))
|
179 |
+
plt.text(0.5, 0.5, 'Please generate the schedule first before viewing analytics.',
|
180 |
+
horizontalalignment='center', verticalalignment='center',
|
181 |
+
fontsize=14, color='red')
|
182 |
+
plt.axis('off')
|
183 |
+
plt.tight_layout()
|
184 |
+
plt.show()
|
185 |
return
|
|
|
186 |
"""Generate a bar chart showing matches overseen by each commissioner."""
|
187 |
# Assuming each commissioner oversees a specific conference
|
188 |
comm_dict = {f"Conference {chr(65+i)}": comm for i, comm in enumerate(commissioners)}
|