James McCool commited on
Commit
185a85c
·
1 Parent(s): 939415c

Add Pitcher_Info integration in app.py to enhance player data processing by including LHH and RHH attributes, improving data analysis capabilities for hitters.

Browse files
Files changed (1) hide show
  1. app.py +8 -1
app.py CHANGED
@@ -70,6 +70,13 @@ def init_baselines():
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()
75
  player_frame = pd.DataFrame(cursor)
@@ -79,7 +86,7 @@ def init_baselines():
79
  hold_frame = roo_data.copy()
80
 
81
  hold_frame['Order'] = np.where(hold_frame['pos_group'] == 'Hitters', hold_frame['Player'].map(RHP_Info.set_index('Player')['Order']), 0)
82
- hold_frame['Hand'] = np.where(hold_frame['pos_group'] == 'Hitters', hold_frame['Player'].map(RHP_Info.set_index('Player')['bats']), 'Pitcher')
83
 
84
  roo_data.insert(3, 'Hand', hold_frame['Hand'])
85
  roo_data.insert(4, 'Order', hold_frame['Order'].astype(int))
 
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["Pitcher_Info"]
74
+ cursor = collection.find()
75
+ Pitcher_info = pd.DataFrame(cursor)
76
+ Pitcher_info = Pitcher_info.rename(columns={'Names':'Player'})
77
+ LHH_Info = Pitcher_info[Pitcher_info['Set'] == 'LHH'].drop_duplicates(subset=['Player'])
78
+ RHH_Info = Pitcher_info[Pitcher_info['Set'] == 'RHH'].drop_duplicates(subset=['Player'])
79
+
80
  collection = db["Player_Range_Of_Outcomes"]
81
  cursor = collection.find()
82
  player_frame = pd.DataFrame(cursor)
 
86
  hold_frame = roo_data.copy()
87
 
88
  hold_frame['Order'] = np.where(hold_frame['pos_group'] == 'Hitters', hold_frame['Player'].map(RHP_Info.set_index('Player')['Order']), 0)
89
+ 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']))
90
 
91
  roo_data.insert(3, 'Hand', hold_frame['Hand'])
92
  roo_data.insert(4, 'Order', hold_frame['Order'].astype(int))