James McCool commited on
Commit
6af53eb
·
1 Parent(s): 108ace7

Refactor salary data processing in app.py: streamline salary conversion by consolidating character removal into a single regex operation, enhancing data integrity and consistency during projections file handling.

Browse files
Files changed (1) hide show
  1. app.py +1 -5
app.py CHANGED
@@ -140,10 +140,6 @@ with tab1:
140
  if projections is not None:
141
  st.success('Projections file loaded successfully!')
142
  projections = projections.apply(lambda x: x.replace(player_wrong_names_mlb, player_right_names_mlb))
143
- try:
144
- projections['salary'] = projections['salary'].astype(str).str.replace([',', '$', ' '], '', regex=True).astype(int)
145
- except:
146
- pass
147
  st.dataframe(projections.head(10))
148
 
149
  if portfolio_file and projections_file:
@@ -198,7 +194,7 @@ with tab1:
198
  st.session_state['projections_df']['ownership'] = st.session_state['projections_df']['ownership']
199
 
200
  try:
201
- st.session_state['projections_df']['salary'] = (st.session_state['projections_df']['salary'].astype(str).str.replace(',', '').astype(float).astype(int))
202
  except:
203
  st.session_state['projections_df']['salary'] = st.session_state['projections_df']['salary']
204
 
 
140
  if projections is not None:
141
  st.success('Projections file loaded successfully!')
142
  projections = projections.apply(lambda x: x.replace(player_wrong_names_mlb, player_right_names_mlb))
 
 
 
 
143
  st.dataframe(projections.head(10))
144
 
145
  if portfolio_file and projections_file:
 
194
  st.session_state['projections_df']['ownership'] = st.session_state['projections_df']['ownership']
195
 
196
  try:
197
+ st.session_state['projections_df']['salary'] = (st.session_state['projections_df']['salary'].astype(str).str.replace([',', '$', ' '], '', regex=True).astype(float).astype(int))
198
  except:
199
  st.session_state['projections_df']['salary'] = st.session_state['projections_df']['salary']
200