Spaces:
Sleeping
Sleeping
James McCool
Refactor 'Manage Portfolio' logic to directly use reassess_edge for both working and export frames, streamlining data processing and enhancing efficiency.
0543ffc
| import pandas as pd | |
| from global_func.predict_dupes import predict_dupes | |
| def reassess_edge(modified_frame: pd.DataFrame, base_frame: pd.DataFrame, maps_dict: dict, site_var: str, type_var: str, Contest_Size: int, strength_var: str, sport_var: str, max_salary: int) -> pd.DataFrame: | |
| """ | |
| Reassess edge by concatenating modified frame with base frame, running predict_dupes, | |
| and then extracting the first N rows (where N is the length of modified_frame). | |
| Args: | |
| modified_frame: DataFrame with rows that were modified by exposure_spread | |
| base_frame: Original base frame (base_frame for Portfolio, original export_base for Export) | |
| maps_dict: Dictionary containing player mappings | |
| site_var: Site variable (Draftkings/Fanduel) | |
| type_var: Type variable (Classic/Showdown) | |
| Contest_Size: Contest size for calculations | |
| strength_var: Strength variable (Weak/Average/Sharp) | |
| sport_var: Sport variable | |
| max_salary: Maximum salary for the contest | |
| Returns: | |
| DataFrame: Updated modified_frame with recalculated metrics | |
| """ | |
| # Store the number of rows in the modified frame | |
| num_modified_rows = len(modified_frame) | |
| # Concatenate the modified frame with the base frame | |
| combined_frame = pd.concat([modified_frame.drop(columns=['Dupes', 'Finish_percentile', 'Lineup Edge', 'Win%', 'Weighted Own', 'Geomean', 'Diversity']), base_frame.drop(columns=['Dupes', 'Finish_percentile', 'Lineup Edge', 'Win%', 'Weighted Own', 'Geomean', 'Diversity'])], ignore_index=True) | |
| # Run predict_dupes on the combined frame | |
| updated_combined_frame = predict_dupes(combined_frame, maps_dict, site_var, type_var, Contest_Size, strength_var, sport_var, max_salary) | |
| # Extract the first N rows (which correspond to our modified frame) | |
| result_frame = updated_combined_frame.head(num_modified_rows).copy() | |
| return result_frame |