James McCool commited on
Commit
c2f15fd
·
1 Parent(s): 0d57fec

Enhance app.py by adding name mapping functionality in DK seed frame initialization. This update retrieves player names from the database and maps them to the corresponding columns in the output DataFrame, improving data visibility and accuracy during contest simulations.

Browse files
Files changed (1) hide show
  1. app.py +19 -1
app.py CHANGED
@@ -22,25 +22,43 @@ dk_columns = ['QB', 'RB1', 'RB2', 'WR1', 'WR2', 'WR3', 'TE', 'FLEX', 'DST', 'sal
22
  fd_columns = ['QB', 'RB1', 'RB2', 'WR1', 'WR2', 'WR3', 'TE', 'FLEX', 'DST', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']
23
 
24
  @st.cache_data(ttl = 600)
25
- def init_DK_seed_frames(sharp_split):
 
 
 
 
 
26
 
27
  collection = db["DK_NFL_seed_frame"]
28
  cursor = collection.find().limit(sharp_split)
29
 
30
  raw_display = pd.DataFrame(list(cursor))
31
  raw_display = raw_display[['QB', 'RB1', 'RB2', 'WR1', 'WR2', 'WR3', 'TE', 'FLEX', 'DST', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
 
 
 
 
32
  DK_seed = raw_display.to_numpy()
33
 
34
  return DK_seed
35
 
36
  @st.cache_data(ttl = 600)
37
  def init_DK_Secondary_seed_frames(sharp_split):
 
 
 
 
 
38
 
39
  collection = db["DK_NFL_Secondary_seed_frame"]
40
  cursor = collection.find().limit(sharp_split)
41
 
42
  raw_display = pd.DataFrame(list(cursor))
43
  raw_display = raw_display[['QB', 'RB1', 'RB2', 'WR1', 'WR2', 'WR3', 'TE', 'FLEX', 'DST', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
 
 
 
 
44
  DK_seed = raw_display.to_numpy()
45
 
46
  return DK_seed
 
22
  fd_columns = ['QB', 'RB1', 'RB2', 'WR1', 'WR2', 'WR3', 'TE', 'FLEX', 'DST', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']
23
 
24
  @st.cache_data(ttl = 600)
25
+ def init_DK_seed_frames(sharp_split):
26
+
27
+ collection = db['DK_NFL_name_map']
28
+ cursor = collection.find()
29
+ raw_data = pd.DataFrame(list(cursor))
30
+ names_dict = dict(zip(raw_data['key'], raw_data['value']))
31
 
32
  collection = db["DK_NFL_seed_frame"]
33
  cursor = collection.find().limit(sharp_split)
34
 
35
  raw_display = pd.DataFrame(list(cursor))
36
  raw_display = raw_display[['QB', 'RB1', 'RB2', 'WR1', 'WR2', 'WR3', 'TE', 'FLEX', 'DST', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
37
+ dict_columns = ['QB', 'RB1', 'RB2', 'WR1', 'WR2', 'WR3', 'TE', 'FLEX', 'DST']
38
+ st.write("converting names")
39
+ for col in dict_columns:
40
+ raw_display[col] = raw_display[col].map(names_dict)
41
  DK_seed = raw_display.to_numpy()
42
 
43
  return DK_seed
44
 
45
  @st.cache_data(ttl = 600)
46
  def init_DK_Secondary_seed_frames(sharp_split):
47
+
48
+ collection = db['DK_Secondary_NFL_name_map']
49
+ cursor = collection.find()
50
+ raw_data = pd.DataFrame(list(cursor))
51
+ names_dict = dict(zip(raw_data['key'], raw_data['value']))
52
 
53
  collection = db["DK_NFL_Secondary_seed_frame"]
54
  cursor = collection.find().limit(sharp_split)
55
 
56
  raw_display = pd.DataFrame(list(cursor))
57
  raw_display = raw_display[['QB', 'RB1', 'RB2', 'WR1', 'WR2', 'WR3', 'TE', 'FLEX', 'DST', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
58
+ dict_columns = ['QB', 'RB1', 'RB2', 'WR1', 'WR2', 'WR3', 'TE', 'FLEX', 'DST']
59
+ st.write("converting names")
60
+ for col in dict_columns:
61
+ raw_display[col] = raw_display[col].map(names_dict)
62
  DK_seed = raw_display.to_numpy()
63
 
64
  return DK_seed