James McCool commited on
Commit
46a3d32
·
1 Parent(s): 64f88b0

Refactor init_team_data function in app.py to enhance clarity and streamline table handling. Replaced count_var with a loop to iterate through data tables, improving readability and organization of statistical calculations for team performance metrics. This change contributes to better structure and understanding of kills, deaths, assists, and total CS analysis.

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -116,8 +116,10 @@ def init_team_data(team, opponent, win_loss, kill_prediction, death_prediction,
116
  cursor = collection.find({"Opponent": opponent, "date": {"$gte": start_datetime, "$lte": end_datetime}})
117
  raw_opponent = pd.DataFrame(list(cursor))
118
 
119
- for tables in [raw_display, raw_opponent]:
120
- count_var = 'raw_display' if tables == raw_display else 'raw_opponent'
 
 
121
  calc_columns = ['kills', 'deaths', 'assists', 'total_cs']
122
  league_win_stats = {}
123
  league_loss_stats = {}
@@ -264,7 +266,7 @@ def init_team_data(team, opponent, win_loss, kill_prediction, death_prediction,
264
  tables['playername_avg_assist_share_loss'] = tables['playername_avg_assists_loss'] / tables['teamname_avg_kills_loss']
265
  tables['playername_avg_cs_share_loss'] = tables['playername_avg_total_cs_loss'] / tables['teamname_avg_total_cs_loss']
266
 
267
- if count_var == 'raw_display':
268
  player_tables = tables
269
  else:
270
  opp_tables = tables
 
116
  cursor = collection.find({"Opponent": opponent, "date": {"$gte": start_datetime, "$lte": end_datetime}})
117
  raw_opponent = pd.DataFrame(list(cursor))
118
 
119
+ tables_to_loop = [raw_display, raw_opponent]
120
+
121
+ for loop in range(len(tables_to_loop)):
122
+ tables = tables_to_loop[loop]
123
  calc_columns = ['kills', 'deaths', 'assists', 'total_cs']
124
  league_win_stats = {}
125
  league_loss_stats = {}
 
266
  tables['playername_avg_assist_share_loss'] = tables['playername_avg_assists_loss'] / tables['teamname_avg_kills_loss']
267
  tables['playername_avg_cs_share_loss'] = tables['playername_avg_total_cs_loss'] / tables['teamname_avg_total_cs_loss']
268
 
269
+ if loop == 0:
270
  player_tables = tables
271
  else:
272
  opp_tables = tables