James McCool
commited on
Commit
·
faa4887
1
Parent(s):
90c9193
Enhance load_contest_file function to include EntryCount in cleaned dataframe
Browse files- Updated the cleaned dataframe to calculate and include 'EntryCount' based on the frequency of 'BaseName', improving data insights for further processing.
- This change continues the effort to refine data handling and enhance the overall functionality of the application.
global_func/load_contest_file.py
CHANGED
@@ -40,11 +40,13 @@ def load_contest_file(upload, sport):
|
|
40 |
pos_df = df[['Player', 'Pos']]
|
41 |
|
42 |
# Create the cleaned dataframe with just the essential columns
|
43 |
-
cleaned_df = df[['BaseName', '
|
44 |
cleaned_df['Lineup'] = cleaned_df['Lineup'].replace(pos_list, value=',', regex=True)
|
45 |
check_lineups = cleaned_df.copy()
|
46 |
cleaned_df[['Remove', '1B', '2B', '3B', 'C', 'OF1', 'OF2', 'OF3', 'P1', 'P2', 'SS']] = cleaned_df['Lineup'].str.split(',', expand=True)
|
47 |
cleaned_df = cleaned_df.drop(columns=['Lineup', 'Remove'])
|
|
|
|
|
48 |
cleaned_df = cleaned_df[['BaseName', 'EntryCount', 'P1', 'P2', 'C', '1B', '2B', '3B', 'SS', 'OF1', 'OF2', 'OF3']]
|
49 |
|
50 |
# Get unique entry names
|
|
|
40 |
pos_df = df[['Player', 'Pos']]
|
41 |
|
42 |
# Create the cleaned dataframe with just the essential columns
|
43 |
+
cleaned_df = df[['BaseName', 'Lineup']]
|
44 |
cleaned_df['Lineup'] = cleaned_df['Lineup'].replace(pos_list, value=',', regex=True)
|
45 |
check_lineups = cleaned_df.copy()
|
46 |
cleaned_df[['Remove', '1B', '2B', '3B', 'C', 'OF1', 'OF2', 'OF3', 'P1', 'P2', 'SS']] = cleaned_df['Lineup'].str.split(',', expand=True)
|
47 |
cleaned_df = cleaned_df.drop(columns=['Lineup', 'Remove'])
|
48 |
+
entry_counts = cleaned_df['BaseName'].value_counts()
|
49 |
+
cleaned_df['EntryCount'] = cleaned_df['BaseName'].map(entry_counts)
|
50 |
cleaned_df = cleaned_df[['BaseName', 'EntryCount', 'P1', 'P2', 'C', '1B', '2B', '3B', 'SS', 'OF1', 'OF2', 'OF3']]
|
51 |
|
52 |
# Get unique entry names
|