James McCool commited on
Commit
4af194e
·
1 Parent(s): 901bbc5

Refactor salary processing in app.py: streamline salary conversion by removing unwanted characters before converting to integers, enhancing clarity and ensuring consistent data handling during projections file loading.

Browse files
Files changed (1) hide show
  1. app.py +2 -6
app.py CHANGED
@@ -141,10 +141,11 @@ with tab1:
141
  if projections is not None:
142
  st.success('Projections file loaded successfully!')
143
  try:
144
- projections['salary'] = projections['salary'].str.replace(',', '').str.replace('$', '').str.replace(' ', '').astype(int)
145
  st.write('replaced salary symbols')
146
  except:
147
  pass
 
148
  projections = projections.apply(lambda x: x.replace(player_wrong_names_mlb, player_right_names_mlb))
149
  st.dataframe(projections.head(10))
150
 
@@ -199,11 +200,6 @@ with tab1:
199
  except:
200
  pass
201
 
202
- try:
203
- st.session_state['projections_df']['salary'] = (st.session_state['projections_df']['salary'].astype(str).str.replace([',', '$', ' '], '', regex=True).astype(int))
204
- except:
205
- pass
206
-
207
  try:
208
  name_id_map = dict(zip(
209
  st.session_state['csv_file']['Name'],
 
141
  if projections is not None:
142
  st.success('Projections file loaded successfully!')
143
  try:
144
+ projections['salary'] = projections['salary'].str.replace(',', '').str.replace('$', '').str.replace(' ', '')
145
  st.write('replaced salary symbols')
146
  except:
147
  pass
148
+ projections['salary'] = projections['salary'].astype(int)
149
  projections = projections.apply(lambda x: x.replace(player_wrong_names_mlb, player_right_names_mlb))
150
  st.dataframe(projections.head(10))
151
 
 
200
  except:
201
  pass
202
 
 
 
 
 
 
203
  try:
204
  name_id_map = dict(zip(
205
  st.session_state['csv_file']['Name'],