Spaces:
Running
Running
James McCool
commited on
Commit
·
2615945
1
Parent(s):
202a844
Enhance app.py: Introduce name mapping for player positions in DraftKings and FanDuel seed frame functions. Added functionality to convert player names using dedicated name maps for both main and secondary seed frames, improving data clarity and consistency in player representation.
Browse files
app.py
CHANGED
@@ -23,48 +23,84 @@ fd_columns = ['PG1', 'PG2', 'SG1', 'SG2', 'SF1', 'SF2', 'PF1', 'PF2', 'C1', 'sal
|
|
23 |
|
24 |
@st.cache_data(ttl = 60)
|
25 |
def init_DK_seed_frames(load_size):
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
collection = db["DK_NBA_seed_frame"]
|
28 |
cursor = collection.find().limit(load_size)
|
29 |
|
30 |
raw_display = pd.DataFrame(list(cursor))
|
31 |
raw_display = raw_display[['PG', 'SG', 'SF', 'PF', 'C', 'G', 'F', 'FLEX', '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 = 60)
|
37 |
def init_DK_secondary_seed_frames(load_size):
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
collection = db["DK_NBA_Secondary_seed_frame"]
|
40 |
cursor = collection.find().limit(load_size)
|
41 |
|
42 |
raw_display = pd.DataFrame(list(cursor))
|
43 |
raw_display = raw_display[['PG', 'SG', 'SF', 'PF', 'C', 'G', 'F', 'FLEX', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
|
|
|
|
|
|
|
|
|
44 |
DK_seed = raw_display.to_numpy()
|
45 |
|
46 |
return DK_seed
|
47 |
|
48 |
@st.cache_data(ttl = 60)
|
49 |
def init_FD_seed_frames(load_size):
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
collection = db["FD_NBA_seed_frame"]
|
52 |
cursor = collection.find().limit(load_size)
|
53 |
|
54 |
raw_display = pd.DataFrame(list(cursor))
|
55 |
raw_display = raw_display[['PG1', 'PG2', 'SG1', 'SG2', 'SF1', 'SF2', 'PF1', 'PF2', 'C1', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
|
|
|
|
|
|
|
|
|
56 |
FD_seed = raw_display.to_numpy()
|
57 |
|
58 |
return FD_seed
|
59 |
|
60 |
@st.cache_data(ttl = 60)
|
61 |
def init_FD_secondary_seed_frames(load_size):
|
|
|
|
|
|
|
|
|
|
|
62 |
|
63 |
collection = db["FD_NBA_Secondary_seed_frame"]
|
64 |
cursor = collection.find().limit(load_size)
|
65 |
|
66 |
raw_display = pd.DataFrame(list(cursor))
|
67 |
raw_display = raw_display[['PG1', 'PG2', 'SG1', 'SG2', 'SF1', 'SF2', 'PF1', 'PF2', 'C1', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
|
|
|
|
|
|
|
|
|
68 |
FD_seed = raw_display.to_numpy()
|
69 |
|
70 |
return FD_seed
|
|
|
23 |
|
24 |
@st.cache_data(ttl = 60)
|
25 |
def init_DK_seed_frames(load_size):
|
26 |
+
|
27 |
+
collection = db['DK_NBA_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_NBA_seed_frame"]
|
33 |
cursor = collection.find().limit(load_size)
|
34 |
|
35 |
raw_display = pd.DataFrame(list(cursor))
|
36 |
raw_display = raw_display[['PG', 'SG', 'SF', 'PF', 'C', 'G', 'F', 'FLEX', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
|
37 |
+
dict_columns = ['PG', 'SG', 'SF', 'PF', 'C', 'G', 'F', 'FLEX']
|
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 = 60)
|
46 |
def init_DK_secondary_seed_frames(load_size):
|
47 |
+
|
48 |
+
collection = db['DK_NBA_Secondary_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_NBA_Secondary_seed_frame"]
|
54 |
cursor = collection.find().limit(load_size)
|
55 |
|
56 |
raw_display = pd.DataFrame(list(cursor))
|
57 |
raw_display = raw_display[['PG', 'SG', 'SF', 'PF', 'C', 'G', 'F', 'FLEX', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
|
58 |
+
dict_columns = ['PG', 'SG', 'SF', 'PF', 'C', 'G', 'F', 'FLEX']
|
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
|
65 |
|
66 |
@st.cache_data(ttl = 60)
|
67 |
def init_FD_seed_frames(load_size):
|
68 |
+
|
69 |
+
collection = db['FD_NBA_name_map']
|
70 |
+
cursor = collection.find()
|
71 |
+
raw_data = pd.DataFrame(list(cursor))
|
72 |
+
names_dict = dict(zip(raw_data['key'], raw_data['value']))
|
73 |
|
74 |
collection = db["FD_NBA_seed_frame"]
|
75 |
cursor = collection.find().limit(load_size)
|
76 |
|
77 |
raw_display = pd.DataFrame(list(cursor))
|
78 |
raw_display = raw_display[['PG1', 'PG2', 'SG1', 'SG2', 'SF1', 'SF2', 'PF1', 'PF2', 'C1', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
|
79 |
+
dict_columns = ['PG1', 'PG2', 'SG1', 'SG2', 'SF1', 'SF2', 'PF1', 'PF2', 'C1']
|
80 |
+
st.write("converting names")
|
81 |
+
for col in dict_columns:
|
82 |
+
raw_display[col] = raw_display[col].map(names_dict)
|
83 |
FD_seed = raw_display.to_numpy()
|
84 |
|
85 |
return FD_seed
|
86 |
|
87 |
@st.cache_data(ttl = 60)
|
88 |
def init_FD_secondary_seed_frames(load_size):
|
89 |
+
|
90 |
+
collection = db['FD_NBA_Secondary_name_map']
|
91 |
+
cursor = collection.find()
|
92 |
+
raw_data = pd.DataFrame(list(cursor))
|
93 |
+
names_dict = dict(zip(raw_data['key'], raw_data['value']))
|
94 |
|
95 |
collection = db["FD_NBA_Secondary_seed_frame"]
|
96 |
cursor = collection.find().limit(load_size)
|
97 |
|
98 |
raw_display = pd.DataFrame(list(cursor))
|
99 |
raw_display = raw_display[['PG1', 'PG2', 'SG1', 'SG2', 'SF1', 'SF2', 'PF1', 'PF2', 'C1', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
|
100 |
+
dict_columns = ['PG1', 'PG2', 'SG1', 'SG2', 'SF1', 'SF2', 'PF1', 'PF2', 'C1']
|
101 |
+
st.write("converting names")
|
102 |
+
for col in dict_columns:
|
103 |
+
raw_display[col] = raw_display[col].map(names_dict)
|
104 |
FD_seed = raw_display.to_numpy()
|
105 |
|
106 |
return FD_seed
|