James McCool
commited on
Commit
·
16fbcab
1
Parent(s):
c65f6e6
Refactor percentile finish calculation in app.py
Browse files- Updated the calculation of the 'percentile_finish' column to use the index after resetting it, improving the accuracy of percentile rankings.
- Removed the 'sorted' column along with the index to streamline the dataframe, enhancing overall data processing efficiency.
app.py
CHANGED
@@ -147,8 +147,9 @@ with tab2:
|
|
147 |
axis=1
|
148 |
)
|
149 |
working_df['dupes'] = working_df.groupby('sorted').transform('size')
|
150 |
-
working_df
|
151 |
-
working_df = working_df.
|
|
|
152 |
elif type_var == 'Showdown':
|
153 |
working_df['stack'] = working_df.apply(
|
154 |
lambda row: Counter(
|
@@ -184,8 +185,9 @@ with tab2:
|
|
184 |
axis=1
|
185 |
)
|
186 |
working_df['dupes'] = working_df.groupby('sorted').transform('size')
|
187 |
-
working_df
|
188 |
-
working_df = working_df.
|
|
|
189 |
|
190 |
# Initialize pagination in session state if not exists
|
191 |
if 'current_page' not in st.session_state:
|
|
|
147 |
axis=1
|
148 |
)
|
149 |
working_df['dupes'] = working_df.groupby('sorted').transform('size')
|
150 |
+
working_df = working_df.reset_index()
|
151 |
+
working_df['percentile_finish'] = working_df['index'].rank(pct=True)
|
152 |
+
working_df = working_df.drop(['sorted', 'index'], axis=1)
|
153 |
elif type_var == 'Showdown':
|
154 |
working_df['stack'] = working_df.apply(
|
155 |
lambda row: Counter(
|
|
|
185 |
axis=1
|
186 |
)
|
187 |
working_df['dupes'] = working_df.groupby('sorted').transform('size')
|
188 |
+
working_df = working_df.reset_index()
|
189 |
+
working_df['percentile_finish'] = working_df['index'].rank(pct=True)
|
190 |
+
working_df = working_df.drop(['sorted', 'index'], axis=1)
|
191 |
|
192 |
# Initialize pagination in session state if not exists
|
193 |
if 'current_page' not in st.session_state:
|