Spaces:
Running
Running
James McCool
commited on
Commit
·
96aabe9
1
Parent(s):
b2e59e8
Refactor Hitter_Info integration in app.py to separate LHP and RHP data, ensuring accurate mapping of 'Order' and 'Hand' attributes for hitters, enhancing data processing and analysis capabilities.
Browse files
app.py
CHANGED
@@ -67,6 +67,8 @@ def init_baselines():
|
|
67 |
collection = db["Hitter_Info"]
|
68 |
cursor = collection.find()
|
69 |
Hitter_info = pd.DataFrame(cursor)
|
|
|
|
|
70 |
|
71 |
collection = db["Player_Range_Of_Outcomes"]
|
72 |
cursor = collection.find()
|
@@ -74,8 +76,8 @@ def init_baselines():
|
|
74 |
|
75 |
roo_data = player_frame.drop(columns=['_id'])
|
76 |
roo_data['Salary'] = roo_data['Salary'].astype(int)
|
77 |
-
roo_data['Order'] = np.where(roo_data['pos_group'] == 'Hitters', roo_data['Player'].map(
|
78 |
-
roo_data['Hand'] = np.where(roo_data['pos_group'] == 'Hitters', roo_data['Player'].map(
|
79 |
|
80 |
dk_roo = roo_data[roo_data['Site'] == 'Draftkings']
|
81 |
dk_id_map = dict(zip(dk_roo['Player'], dk_roo['player_ID']))
|
|
|
67 |
collection = db["Hitter_Info"]
|
68 |
cursor = collection.find()
|
69 |
Hitter_info = pd.DataFrame(cursor)
|
70 |
+
LHP_Info = Hitter_info[Hitter_info['Set'] == 'LHP'].drop_duplicates(subset=['Player'])
|
71 |
+
RHP_Info = Hitter_info[Hitter_info['Set'] == 'RHP'].drop_duplicates(subset=['Player'])
|
72 |
|
73 |
collection = db["Player_Range_Of_Outcomes"]
|
74 |
cursor = collection.find()
|
|
|
76 |
|
77 |
roo_data = player_frame.drop(columns=['_id'])
|
78 |
roo_data['Salary'] = roo_data['Salary'].astype(int)
|
79 |
+
roo_data['Order'] = np.where(roo_data['pos_group'] == 'Hitters', roo_data['Player'].map(RHP_Info.set_index('Player')['Order']), '')
|
80 |
+
roo_data['Hand'] = np.where(roo_data['pos_group'] == 'Hitters', roo_data['Player'].map(RHP_Info.set_index('Player')['bats']), '')
|
81 |
|
82 |
dk_roo = roo_data[roo_data['Site'] == 'Draftkings']
|
83 |
dk_id_map = dict(zip(dk_roo['Player'], dk_roo['player_ID']))
|