James McCool commited on
Commit
55a782f
·
1 Parent(s): c2b7029

Add unique and under-5 duplicate counts to working_df in app.py

Browse files

- Implemented calculations for unique lineups and lineups with 5 or fewer duplicates for each BaseName, enhancing data analysis capabilities within the application.

Files changed (1) hide show
  1. app.py +9 -0
app.py CHANGED
@@ -221,6 +221,15 @@ with tab2:
221
  axis=1
222
  )
223
  working_df['dupes'] = working_df.groupby('sorted').transform('size')
 
 
 
 
 
 
 
 
 
224
  working_df = working_df.reset_index()
225
  working_df['percentile_finish'] = working_df['index'].rank(pct=True)
226
  working_df['finish'] = working_df['index']
 
221
  axis=1
222
  )
223
  working_df['dupes'] = working_df.groupby('sorted').transform('size')
224
+ # For uniques - count how many unique lineups (dupes == 1) each BaseName has
225
+ working_df['uniques'] = working_df.groupby('BaseName').apply(
226
+ lambda x: (x['dupes'] == 1).sum()
227
+ ).reindex(working_df['BaseName']).values
228
+
229
+ # For under_5 - count how many lineups with 5 or fewer duplicates each BaseName has
230
+ working_df['under_5'] = working_df.groupby('BaseName').apply(
231
+ lambda x: (x['dupes'] <= 5).sum()
232
+ ).reindex(working_df['BaseName']).values
233
  working_df = working_df.reset_index()
234
  working_df['percentile_finish'] = working_df['index'].rank(pct=True)
235
  working_df['finish'] = working_df['index']