Spaces:
Running
Running
James McCool
commited on
Commit
·
f29027b
1
Parent(s):
7e17f0f
Refactor player summary generation in app.py to utilize results_dict for improved performance metrics aggregation. Updated the init_team_data function to return results_dict instead of player_summary, and added logic to clean player names for better clarity. This change enhances the overall organization of player statistics and streamlines the data handling process during simulations.
Browse files
app.py
CHANGED
@@ -346,22 +346,27 @@ def init_team_data(team, opponent, win_loss_settings, kill_predictions, death_pr
|
|
346 |
results_dict[f'game {game + 1}'] = team_data
|
347 |
team_data['playername'] = team_data['playername'] + f' game {game + 1}'
|
348 |
|
349 |
-
player_summary = pd.DataFrame()
|
350 |
-
for game_count, game_df in results_dict.items():
|
351 |
-
if player_summary.empty:
|
352 |
-
player_summary = game_df
|
353 |
-
else:
|
354 |
-
player_summary.update(game_df)
|
355 |
-
for col in ['Kill_Proj', 'Death_Proj', 'Assist_Proj', 'CS_Proj']:
|
356 |
-
player_summary[col] += game_df[col]
|
357 |
-
player_summary = player_summary.set_index('playername')
|
358 |
-
|
359 |
overall_team_data = pd.concat([overall_team_data, team_data])
|
360 |
|
361 |
-
return overall_team_data.dropna().set_index('playername'), opp_boosts,
|
362 |
|
363 |
if st.button("Run"):
|
364 |
-
team_data, opp_boost,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
365 |
|
366 |
# Create simulated percentiles
|
367 |
sim_results = []
|
|
|
346 |
results_dict[f'game {game + 1}'] = team_data
|
347 |
team_data['playername'] = team_data['playername'] + f' game {game + 1}'
|
348 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
349 |
overall_team_data = pd.concat([overall_team_data, team_data])
|
350 |
|
351 |
+
return overall_team_data.dropna().set_index('playername'), opp_boosts, results_dict
|
352 |
|
353 |
if st.button("Run"):
|
354 |
+
team_data, opp_boost, results_dict = init_team_data(selected_team, selected_opponent, win_loss_settings, kill_predictions, death_predictions, start_date, end_date)
|
355 |
+
|
356 |
+
player_summary = pd.DataFrame()
|
357 |
+
for game_num, game_df in results_dict.items():
|
358 |
+
# Remove 'game X' from playernames if present
|
359 |
+
clean_df = game_df.copy()
|
360 |
+
clean_df['playername'] = clean_df['playername'].str.split(' game ').str[0]
|
361 |
+
|
362 |
+
if player_summary.empty:
|
363 |
+
player_summary = clean_df
|
364 |
+
else:
|
365 |
+
# Add the stats to existing players
|
366 |
+
player_summary.update(clean_df) # Update teamname and position if needed
|
367 |
+
for col in ['Kill_Proj', 'Death_Proj', 'Assist_Proj', 'CS_Proj']:
|
368 |
+
player_summary[col] += clean_df[col]
|
369 |
+
player_summary = player_summary.set_index('playername')
|
370 |
|
371 |
# Create simulated percentiles
|
372 |
sim_results = []
|