James McCool commited on
Commit
043582a
·
1 Parent(s): f70d907

Refactor seed frame initialization functions to handle multiple slate types for DraftKings and FanDuel, improving data retrieval and organization based on slate selection.

Browse files
src/sim_func_hold/regular_functions.py CHANGED
@@ -7,11 +7,26 @@ from database import db
7
  @st.cache_data(ttl = 600)
8
  def init_DK_seed_frames(slate_var, sharp_split):
9
 
10
- collection = db['DK_NFL_name_map']
11
- cursor = collection.find()
12
- raw_data = pd.DataFrame(list(cursor))
13
- names_dict = dict(zip(raw_data['key'], raw_data['value']))
14
- collection = db[f"DK_NFL_{slate_var}_seed_frame"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  cursor = collection.find().limit(sharp_split)
16
 
17
  raw_display = pd.DataFrame(list(cursor))
@@ -26,13 +41,27 @@ def init_DK_seed_frames(slate_var, sharp_split):
26
  @st.cache_data(ttl = 599)
27
  def init_FD_seed_frames(slate_var, sharp_split):
28
 
29
- collection = db['FD_NFL_name_map']
30
- cursor = collection.find()
31
- raw_data = pd.DataFrame(list(cursor))
32
- names_dict = dict(zip(raw_data['key'], raw_data['value']))
33
-
34
- collection = db[f"FD_NFL_{slate_var}_seed_frame"]
35
- cursor = collection.find().limit(sharp_split)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
  raw_display = pd.DataFrame(list(cursor))
38
  raw_display = raw_display[['QB', 'RB1', 'RB2', 'WR1', 'WR2', 'WR3', 'TE', 'FLEX', 'DST', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
 
7
  @st.cache_data(ttl = 600)
8
  def init_DK_seed_frames(slate_var, sharp_split):
9
 
10
+
11
+ if slate_var == 'Main Slate':
12
+ collection = db['DK_NFL_name_map']
13
+ cursor = collection.find()
14
+ raw_data = pd.DataFrame(list(cursor))
15
+ names_dict = dict(zip(raw_data['key'], raw_data['value']))
16
+ collection = db[f"DK_NFL_seed_frame"]
17
+ elif slate_var == 'Secondary Slate':
18
+ collection = db['DK_NFL_Secondary_name_map']
19
+ cursor = collection.find()
20
+ raw_data = pd.DataFrame(list(cursor))
21
+ names_dict = dict(zip(raw_data['key'], raw_data['value']))
22
+ collection = db[f"DK_NFL_Secondary_seed_frame"]
23
+ elif slate_var == 'Auxiliary Slate':
24
+ collection = db['DK_NFL_Auxiliary_name_map']
25
+ cursor = collection.find()
26
+ raw_data = pd.DataFrame(list(cursor))
27
+ names_dict = dict(zip(raw_data['key'], raw_data['value']))
28
+ collection = db[f"DK_NFL_Auxiliary_seed_frame"]
29
+
30
  cursor = collection.find().limit(sharp_split)
31
 
32
  raw_display = pd.DataFrame(list(cursor))
 
41
  @st.cache_data(ttl = 599)
42
  def init_FD_seed_frames(slate_var, sharp_split):
43
 
44
+ if slate_var == 'Main Slate':
45
+ collection = db['FD_NFL_name_map']
46
+ cursor = collection.find()
47
+ raw_data = pd.DataFrame(list(cursor))
48
+ names_dict = dict(zip(raw_data['key'], raw_data['value']))
49
+ collection = db[f"FD_NFL_seed_frame"]
50
+ cursor = collection.find().limit(sharp_split)
51
+ elif slate_var == 'Secondary Slate':
52
+ collection = db['FD_NFL_Secondary_name_map']
53
+ cursor = collection.find()
54
+ raw_data = pd.DataFrame(list(cursor))
55
+ names_dict = dict(zip(raw_data['key'], raw_data['value']))
56
+ collection = db[f"FD_NFL_Secondary_seed_frame"]
57
+ cursor = collection.find().limit(sharp_split)
58
+ elif slate_var == 'Auxiliary Slate':
59
+ collection = db['FD_NFL_Auxiliary_name_map']
60
+ cursor = collection.find()
61
+ raw_data = pd.DataFrame(list(cursor))
62
+ names_dict = dict(zip(raw_data['key'], raw_data['value']))
63
+ collection = db[f"FD_NFL_Auxiliary_seed_frame"]
64
+ cursor = collection.find().limit(sharp_split)
65
 
66
  raw_display = pd.DataFrame(list(cursor))
67
  raw_display = raw_display[['QB', 'RB1', 'RB2', 'WR1', 'WR2', 'WR3', 'TE', 'FLEX', 'DST', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]