James McCool commited on
Commit
a67075a
·
1 Parent(s): fbd699f

Enhance DK and FD lineup initialization by mapping player names from database collections. Added functionality to convert player identifiers to names for improved display in lineups.

Browse files
Files changed (1) hide show
  1. app.py +18 -0
app.py CHANGED
@@ -124,24 +124,42 @@ def load_overall_stats():
124
 
125
  @st.cache_data(ttl = 60)
126
  def init_DK_lineups():
 
 
 
 
 
127
 
128
  collection = db["DK_NBA_seed_frame"]
129
  cursor = collection.find().limit(10000)
130
 
131
  raw_display = pd.DataFrame(list(cursor))
132
  raw_display = raw_display[['PG', 'SG', 'SF', 'PF', 'C', 'G', 'F', 'FLEX', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
 
 
 
 
133
  DK_seed = raw_display.to_numpy()
134
 
135
  return DK_seed
136
 
137
  @st.cache_data(ttl = 60)
138
  def init_FD_lineups():
 
 
 
 
 
139
 
140
  collection = db["FD_NBA_seed_frame"]
141
  cursor = collection.find().limit(10000)
142
 
143
  raw_display = pd.DataFrame(list(cursor))
144
  raw_display = raw_display[['PG1', 'PG2', 'SG1', 'SG2', 'SF1', 'SF2', 'PF1', 'PF2', 'C1', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
 
 
 
 
145
  FD_seed = raw_display.to_numpy()
146
 
147
  return FD_seed
 
124
 
125
  @st.cache_data(ttl = 60)
126
  def init_DK_lineups():
127
+
128
+ collection = db['DK_NBA_name_map']
129
+ cursor = collection.find()
130
+ raw_data = pd.DataFrame(list(cursor))
131
+ names_dict = dict(zip(raw_data['key'], raw_data['value']))
132
 
133
  collection = db["DK_NBA_seed_frame"]
134
  cursor = collection.find().limit(10000)
135
 
136
  raw_display = pd.DataFrame(list(cursor))
137
  raw_display = raw_display[['PG', 'SG', 'SF', 'PF', 'C', 'G', 'F', 'FLEX', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
138
+ dict_columns = ['PG', 'SG', 'SF', 'PF', 'C', 'G', 'F', 'FLEX']
139
+ st.write("converting names")
140
+ for col in dict_columns:
141
+ raw_display[col] = raw_display[col].map(names_dict)
142
  DK_seed = raw_display.to_numpy()
143
 
144
  return DK_seed
145
 
146
  @st.cache_data(ttl = 60)
147
  def init_FD_lineups():
148
+
149
+ collection = db['FD_NBA_name_map']
150
+ cursor = collection.find()
151
+ raw_data = pd.DataFrame(list(cursor))
152
+ names_dict = dict(zip(raw_data['key'], raw_data['value']))
153
 
154
  collection = db["FD_NBA_seed_frame"]
155
  cursor = collection.find().limit(10000)
156
 
157
  raw_display = pd.DataFrame(list(cursor))
158
  raw_display = raw_display[['PG1', 'PG2', 'SG1', 'SG2', 'SF1', 'SF2', 'PF1', 'PF2', 'C1', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
159
+ dict_columns = ['PG1', 'PG2', 'SG1', 'SG2', 'SF1', 'SF2', 'PF1', 'PF2', 'C1']
160
+ st.write("converting names")
161
+ for col in dict_columns:
162
+ raw_display[col] = raw_display[col].map(names_dict)
163
  FD_seed = raw_display.to_numpy()
164
 
165
  return FD_seed