From 6c066d0bad9fec95a129c53dff887e48d2f1d27f Mon Sep 17 00:00:00 2001 From: aberges-SLAC Date: Wed, 20 Nov 2024 13:17:12 -0800 Subject: [PATCH] MNT: Fix pandas 3.0 future warnings about silent downcasting --- scripts/grep_more_ioc.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/scripts/grep_more_ioc.py b/scripts/grep_more_ioc.py index 9e52d0e5..0e03130b 100644 --- a/scripts/grep_more_ioc.py +++ b/scripts/grep_more_ioc.py @@ -492,15 +492,19 @@ def main(): # pad the disable column based on the grep_ioc output if 'disable' not in df.columns: df['disable'] = df.index.size*[False] - if 'disable' in df.columns: - df['disable'] = df['disable'].fillna(False).astype(bool) + # handle stupid pandas 3.0 future warnings early + with pd.option_context('future.no_silent_downcasting', True): + if 'disable' in df.columns: + df['disable'] = (df['disable'].infer_objects().fillna(False)) # Fill the NaN with empty strings for rarely used keys - for _col in df.columns: - if _col not in ['delay']: - df[_col] = df[_col].fillna('') - else: - df[_col] = df[_col].fillna(0) + # handle stupid pandas 3.0 future warnings early + with pd.option_context('future.no_silent_downcasting', True): + for _col in df.columns: + if _col not in ['delay']: + df[_col] = df[_col].infer_objects().fillna('') + else: + df[_col] = df[_col].infer_objects().fillna(0) # check for the ignore_disabled flag if args.ignore_disabled is True: