James McCool
commited on
Commit
·
044bb1e
1
Parent(s):
97d02d3
Refactor position filtering logic in create_position_export_dict to use DataFrame indexing for improved clarity and performance in filtering positions across various sports.
Browse files
app.py
CHANGED
|
@@ -53,13 +53,13 @@ def create_position_export_dict(column_name, csv_file, site_var, type_var, sport
|
|
| 53 |
filtered_df = csv_file.copy()
|
| 54 |
elif position_filter == 'FLEX' or position_filter == 'UTIL':
|
| 55 |
if sport_var == 'NFL':
|
| 56 |
-
filtered_df = csv_file['Position'].isin(['RB', 'WR', 'TE'])
|
| 57 |
elif sport_var == 'SOC':
|
| 58 |
-
filtered_df = csv_file['Position'].str.contains(
|
| 59 |
elif sport_var == 'NCAAF':
|
| 60 |
-
filtered_df = csv_file['Position'].str.contains(
|
| 61 |
elif sport_var == 'NHL':
|
| 62 |
-
filtered_df = csv_file['Position'].str.contains(
|
| 63 |
else:
|
| 64 |
filtered_df = csv_file.copy()
|
| 65 |
elif position_filter == 'SFLEX':
|
|
|
|
| 53 |
filtered_df = csv_file.copy()
|
| 54 |
elif position_filter == 'FLEX' or position_filter == 'UTIL':
|
| 55 |
if sport_var == 'NFL':
|
| 56 |
+
filtered_df = csv_file[csv_file['Position'].isin(['RB', 'WR', 'TE'])]
|
| 57 |
elif sport_var == 'SOC':
|
| 58 |
+
filtered_df = csv_file[csv_file['Position'].str.contains('D|M|F', na=False, regex=True)]
|
| 59 |
elif sport_var == 'NCAAF':
|
| 60 |
+
filtered_df = csv_file[csv_file['Position'].str.contains('RB|WR', na=False, regex=True)]
|
| 61 |
elif sport_var == 'NHL':
|
| 62 |
+
filtered_df = csv_file[csv_file['Position'].str.contains('C|W|D', na=False, regex=True)]
|
| 63 |
else:
|
| 64 |
filtered_df = csv_file.copy()
|
| 65 |
elif position_filter == 'SFLEX':
|