Spaces:
Running
Running
James McCool
commited on
Commit
·
14be3da
1
Parent(s):
c1e67a6
Integrate pitcher information into baseline initialization by adding LHH and RHH dataframes. Update player hand mapping logic to accommodate both left-handed and right-handed hitters, enhancing overall data accuracy for player statistics.
Browse files
app.py
CHANGED
@@ -36,6 +36,13 @@ def init_baselines():
|
|
36 |
LHP_Info = Hitter_info[Hitter_info['Set'] == 'LHP'].drop_duplicates(subset=['Player'])
|
37 |
RHP_Info = Hitter_info[Hitter_info['Set'] == 'RHP'].drop_duplicates(subset=['Player'])
|
38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
collection = db["Player_Range_Of_Outcomes"]
|
40 |
cursor = collection.find()
|
41 |
player_frame = pd.DataFrame(cursor)
|
@@ -45,7 +52,7 @@ def init_baselines():
|
|
45 |
hold_frame = roo_data.copy()
|
46 |
|
47 |
hold_frame['Order'] = np.where(hold_frame['pos_group'] == 'Hitters', hold_frame['Player'].map(RHP_Info.set_index('Player')['Order']), 0)
|
48 |
-
hold_frame['Hand'] = np.where(hold_frame['pos_group'] == 'Hitters', hold_frame['Player'].map(RHP_Info.set_index('Player')['bats']), '
|
49 |
|
50 |
roo_data.insert(3, 'Hand', hold_frame['Hand'])
|
51 |
roo_data.insert(4, 'Order', hold_frame['Order'].astype(int))
|
|
|
36 |
LHP_Info = Hitter_info[Hitter_info['Set'] == 'LHP'].drop_duplicates(subset=['Player'])
|
37 |
RHP_Info = Hitter_info[Hitter_info['Set'] == 'RHP'].drop_duplicates(subset=['Player'])
|
38 |
|
39 |
+
collection = db["Pitcher_Info"]
|
40 |
+
cursor = collection.find()
|
41 |
+
Pitcher_info = pd.DataFrame(cursor)
|
42 |
+
Pitcher_info = Pitcher_info.rename(columns={'Names':'Player'})
|
43 |
+
LHH_Info = Pitcher_info[Pitcher_info['Set'] == 'LHH'].drop_duplicates(subset=['Player'])
|
44 |
+
RHH_Info = Pitcher_info[Pitcher_info['Set'] == 'RHH'].drop_duplicates(subset=['Player'])
|
45 |
+
|
46 |
collection = db["Player_Range_Of_Outcomes"]
|
47 |
cursor = collection.find()
|
48 |
player_frame = pd.DataFrame(cursor)
|
|
|
52 |
hold_frame = roo_data.copy()
|
53 |
|
54 |
hold_frame['Order'] = np.where(hold_frame['pos_group'] == 'Hitters', hold_frame['Player'].map(RHP_Info.set_index('Player')['Order']), 0)
|
55 |
+
hold_frame['Hand'] = np.where(hold_frame['pos_group'] == 'Hitters', hold_frame['Player'].map(RHP_Info.set_index('Player')['bats']), hold_frame['Player'].map(RHH_Info.set_index('Player')['Hand']))
|
56 |
|
57 |
roo_data.insert(3, 'Hand', hold_frame['Hand'])
|
58 |
roo_data.insert(4, 'Order', hold_frame['Order'].astype(int))
|