diff --git a/fieldExtraction/src/investment/investment_postprocessing_funcs.py b/fieldExtraction/src/investment/investment_postprocessing_funcs.py index 1e237e9..78e0998 100644 --- a/fieldExtraction/src/investment/investment_postprocessing_funcs.py +++ b/fieldExtraction/src/investment/investment_postprocessing_funcs.py @@ -347,23 +347,6 @@ def auto_renewal(df: pd.DataFrame) -> pd.DataFrame: df["AUTO_RENEWAL_TERM"] = df["AUTO_RENEWAL_TERM"].apply(normalize_auto_renewal_term) return df -# Special handling for derived termination date if auto-renewal is present -def handle_auto_renewal_termination_date(df: pd.DataFrame) -> pd.DataFrame: - """ - Handles the derived termination date for rows where auto-renewal is indicated. - - Args: - df (pd.DataFrame): The input DataFrame. - - Returns: - pd.DataFrame: The updated DataFrame with derived termination dates adjusted for auto-renewal. - """ - if "AARETE_DERIVED_TERMINATION_DT" in df.columns and "AUTO_RENEWAL_IND" in df.columns: - df.loc[ - df["AUTO_RENEWAL_IND"] == "Y", - "AARETE_DERIVED_TERMINATION_DT" - ] = "9999/01/01" - return df def update_termination_date_for_conditions(df: pd.DataFrame) -> pd.DataFrame: """ @@ -376,13 +359,22 @@ def update_termination_date_for_conditions(df: pd.DataFrame) -> pd.DataFrame: Returns: pd.DataFrame: The updated DataFrame with modified 'AARETE_DERIVED_TERMINATION_DT' values. """ + if "TERMINATION_DT" in df.columns and "AUTO_RENEWAL_IND" in df.columns and "AARETE_DERIVED_TERMINATION_DT" in df.columns: + # Replace Y with 9999/12/31 + df.loc[ + df["AUTO_RENEWAL_IND"] == "Y", + "AARETE_DERIVED_TERMINATION_DT" + ] = "9999/12/31" + + # Replace "N" and "year to year" with 9999/12/31 df.loc[ (df["TERMINATION_DT"] == "year to year") & (df["AUTO_RENEWAL_IND"] == "N") & (df["AARETE_DERIVED_TERMINATION_DT"] == "N/A"), "AARETE_DERIVED_TERMINATION_DT" - ] = "9999/01/01" + ] = "9999/12/31" + return df def standardize_reimb_method_and_fee_schedule(df: pd.DataFrame) -> pd.DataFrame: diff --git a/fieldExtraction/src/investment/postprocess.py b/fieldExtraction/src/investment/postprocess.py index 997bd71..5909441 100644 --- a/fieldExtraction/src/investment/postprocess.py +++ b/fieldExtraction/src/investment/postprocess.py @@ -49,9 +49,6 @@ def postprocess(df): # Normalize the 'AUTO_RENEWAL_TERM' column df = investment_postprocessing_funcs.auto_renewal(df) - - # Special handling for derived termination date if auto-renewal is present - df = investment_postprocessing_funcs.handle_auto_renewal_termination_date(df) # Check conditions for TERMINATION_DT, AUTO_RENEWAL_IND, and AARETE_DERIVED_TERMINATION_DT df = investment_postprocessing_funcs.update_termination_date_for_conditions(df)