James McCool
commited on
Commit
·
a87b532
1
Parent(s):
1ba31e0
Enhance lineup processing in `load_file.py` to improve data extraction
Browse files- Updated the logic for splitting the `Lineup` column into individual player entries, now including an additional column for accurate position mapping.
- Added functionality to remove position indicators from the beginning of each player entry, ensuring cleaner data and preventing misinterpretation of player names.
- global_func/load_file.py +4 -2
global_func/load_file.py
CHANGED
@@ -26,9 +26,11 @@ def load_file(upload):
|
|
26 |
# and not those that might appear within player names
|
27 |
df['Lineup'] = df['Lineup'].str.replace(r'\b(' + '|'.join(pos_values) + r')\b', r'\1,', regex=True)
|
28 |
|
29 |
-
# Split into individual columns
|
30 |
-
for i in range(0,
|
31 |
df[i] = df['Lineup'].str.split(',').str[i].str.strip()
|
|
|
|
|
32 |
position_dict = dict(zip(df['Player'], df['Pos']))
|
33 |
ownership_dict = dict(zip(df['Player'], df['Own']))
|
34 |
entry_list = list(set(df['EntryName']))
|
|
|
26 |
# and not those that might appear within player names
|
27 |
df['Lineup'] = df['Lineup'].str.replace(r'\b(' + '|'.join(pos_values) + r')\b', r'\1,', regex=True)
|
28 |
|
29 |
+
# Split into individual columns and remove position indicators
|
30 |
+
for i in range(0,10):
|
31 |
df[i] = df['Lineup'].str.split(',').str[i].str.strip()
|
32 |
+
# Remove position indicators from the beginning of each entry
|
33 |
+
df[i] = df[i].str.replace(r'^(' + '|'.join(pos_values) + r')\s+', '', regex=True)
|
34 |
position_dict = dict(zip(df['Player'], df['Pos']))
|
35 |
ownership_dict = dict(zip(df['Player'], df['Own']))
|
36 |
entry_list = list(set(df['EntryName']))
|