From 21e71c405446917cbcefced0cb2ef46c8b20d90b Mon Sep 17 00:00:00 2001 From: Rahul Ailaboina Date: Thu, 10 Apr 2025 15:34:06 +0000 Subject: [PATCH] Merged in hotfix/molina_files (pull request #473) Hotfix/molina files * fix the cpt fields * None values checking safely Approved-by: Alex Galarce --- fieldExtraction/src/investment/postprocess.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fieldExtraction/src/investment/postprocess.py b/fieldExtraction/src/investment/postprocess.py index c365c2e..761bf91 100644 --- a/fieldExtraction/src/investment/postprocess.py +++ b/fieldExtraction/src/investment/postprocess.py @@ -186,7 +186,7 @@ def normalize_cpt_fields(value): Returns: list: A normalized list of string codes. """ - if pd.isna(value): # Handle NaN values + if value is None or (isinstance(value, float) and pd.isna(value)): # Handle NaN values result = [] elif isinstance(value, (list, tuple)): # If already a list or tuple result = [str(v).strip() for v in value] @@ -238,7 +238,6 @@ def postprocess(df): df.loc[~df['DATE_VALID'], col] = df.loc[~df['DATE_VALID'], col].apply(reformat_to_yyyymmdd) if "CPT" in col: df[col] = df[col].apply(normalize_cpt_fields) - df[col] = df[col].apply(lambda x: str(x) if isinstance(x, list) else x) # Normalize the 'AUTO_RENEWAL_TERM' column df["AUTO_RENEWAL_TERM"] = df["AUTO_RENEWAL_TERM"].apply(normalize_auto_renewal_term)