James McCool
commited on
Commit
·
7d5d8db
1
Parent(s):
5d46f35
Update stack size handling in app.py to ensure consistent data types
Browse files- Added fillna(1).astype(int) to the stack_size column in multiple locations to ensure that missing values are replaced with 1 and the data type is consistently set to integer, enhancing data integrity during calculations.
app.py
CHANGED
@@ -159,6 +159,7 @@ with tab2:
|
|
159 |
}
|
160 |
# Create a copy of the dataframe for calculations
|
161 |
working_df = st.session_state['Contest'].copy()
|
|
|
162 |
|
163 |
if type_var == 'Classic':
|
164 |
working_df['stack'] = working_df.apply(
|
@@ -225,6 +226,7 @@ with tab2:
|
|
225 |
working_df['percentile_finish'] = working_df['index'].rank(pct=True)
|
226 |
working_df['finish'] = working_df['index']
|
227 |
working_df = working_df.drop(['sorted', 'index'], axis=1)
|
|
|
228 |
st.session_state['field_player_frame'] = create_player_exposures(working_df, player_columns)
|
229 |
st.session_state['field_stack_frame'] = create_stack_exposures(working_df)
|
230 |
|
@@ -260,7 +262,6 @@ with tab2:
|
|
260 |
if stack_parse_var == 'Specific' and stack_names:
|
261 |
working_df = working_df[working_df['stack'].isin(stack_names)]
|
262 |
if low_stack_size_var and high_stack_size_var:
|
263 |
-
working_df['stack_size'] = working_df['stack_size'].fillna(1)
|
264 |
working_df = working_df[working_df['stack_size'].between(low_stack_size_var, high_stack_size_var)]
|
265 |
# if player_parse_var == 'Specific' and player_names:
|
266 |
# working_df = working_df[working_df['BaseName'].isin(player_names)]
|
|
|
159 |
}
|
160 |
# Create a copy of the dataframe for calculations
|
161 |
working_df = st.session_state['Contest'].copy()
|
162 |
+
working_df['stack_size'] = working_df['stack_size'].fillna(1).astype(int)
|
163 |
|
164 |
if type_var == 'Classic':
|
165 |
working_df['stack'] = working_df.apply(
|
|
|
226 |
working_df['percentile_finish'] = working_df['index'].rank(pct=True)
|
227 |
working_df['finish'] = working_df['index']
|
228 |
working_df = working_df.drop(['sorted', 'index'], axis=1)
|
229 |
+
working_df['stack_size'] = working_df['stack_size'].fillna(1).astype(int)
|
230 |
st.session_state['field_player_frame'] = create_player_exposures(working_df, player_columns)
|
231 |
st.session_state['field_stack_frame'] = create_stack_exposures(working_df)
|
232 |
|
|
|
262 |
if stack_parse_var == 'Specific' and stack_names:
|
263 |
working_df = working_df[working_df['stack'].isin(stack_names)]
|
264 |
if low_stack_size_var and high_stack_size_var:
|
|
|
265 |
working_df = working_df[working_df['stack_size'].between(low_stack_size_var, high_stack_size_var)]
|
266 |
# if player_parse_var == 'Specific' and player_names:
|
267 |
# working_df = working_df[working_df['BaseName'].isin(player_names)]
|