James McCool
commited on
Commit
·
baabd98
1
Parent(s):
f6179c3
Reorganize dataframe copy logic in app.py
Browse files- Moved the logic for creating copies of the 'Contest' dataframe and calculating player subsets to a more appropriate location within the code, improving clarity and organization.
- This change enhances the maintainability of the code and ensures that the dataframe manipulations are performed in a logical sequence, facilitating better data processing.
app.py
CHANGED
@@ -101,13 +101,6 @@ with tab2:
|
|
101 |
'cpt_proj_map': dict(zip(st.session_state['projections_df']['player_names'], st.session_state['projections_df']['median'] * 1.5)),
|
102 |
'cpt_own_map': dict(zip(st.session_state['projections_df']['player_names'], st.session_state['projections_df']['captain ownership']))
|
103 |
}
|
104 |
-
# Create a copy of the dataframe for calculations
|
105 |
-
for col in player_columns:
|
106 |
-
contest_players = st.session_state['Contest'].copy()
|
107 |
-
players_1per = st.session_state['Contest'].head(int(len(st.session_state['Contest']) * 0.01))
|
108 |
-
players_5per = st.session_state['Contest'].head(int(len(st.session_state['Contest']) * 0.05))
|
109 |
-
players_10per = st.session_state['Contest'].head(int(len(st.session_state['Contest']) * 0.10))
|
110 |
-
players_20per = st.session_state['Contest'].head(int(len(st.session_state['Contest']) * 0.20))
|
111 |
|
112 |
st.session_state['type_var'] = 'Classic'
|
113 |
|
@@ -175,6 +168,13 @@ with tab2:
|
|
175 |
st.session_state['Contest']['dupes'] = st.session_state['Contest'].groupby('sorted').transform('size')
|
176 |
st.session_state['Contest'] = st.session_state['Contest'].drop('sorted', axis=1)
|
177 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
working_df = st.session_state['Contest'].copy()
|
179 |
|
180 |
with col1:
|
|
|
101 |
'cpt_proj_map': dict(zip(st.session_state['projections_df']['player_names'], st.session_state['projections_df']['median'] * 1.5)),
|
102 |
'cpt_own_map': dict(zip(st.session_state['projections_df']['player_names'], st.session_state['projections_df']['captain ownership']))
|
103 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
|
105 |
st.session_state['type_var'] = 'Classic'
|
106 |
|
|
|
168 |
st.session_state['Contest']['dupes'] = st.session_state['Contest'].groupby('sorted').transform('size')
|
169 |
st.session_state['Contest'] = st.session_state['Contest'].drop('sorted', axis=1)
|
170 |
|
171 |
+
# Create a copy of the dataframe for calculations
|
172 |
+
for col in player_columns:
|
173 |
+
contest_players = st.session_state['Contest'].copy()
|
174 |
+
players_1per = st.session_state['Contest'].head(int(len(st.session_state['Contest']) * 0.01))
|
175 |
+
players_5per = st.session_state['Contest'].head(int(len(st.session_state['Contest']) * 0.05))
|
176 |
+
players_10per = st.session_state['Contest'].head(int(len(st.session_state['Contest']) * 0.10))
|
177 |
+
players_20per = st.session_state['Contest'].head(int(len(st.session_state['Contest']) * 0.20))
|
178 |
working_df = st.session_state['Contest'].copy()
|
179 |
|
180 |
with col1:
|