File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -766,10 +766,15 @@ def impute_missing_values(data):
766766 """
767767 impute_values = \\ \n + {"var1": 0, "var2": "", "var3": 125.3}
768768 """
769- self .score_code += f"\n { '' :4} return data.replace(' .', np.nan).fillna(impute_values).apply(pd.to_numeric, errors='ignore')\n "
769+ self .score_code += f"\n \n { '' :4} # Specify downcasting behavior for pandas 2.x to avoid warnings\n "
770+ self .score_code += f"{ '' :4} if int(pd.__version__.split('.')[0]) == 2:\n { '' :8} pd.set_option('future.no_silent_downcasting', True)\n "
771+ self .score_code += f"{ '' :4} return data.replace(r'^\\ s*\\ .$', np.nan, regex=True).fillna(impute_values).infer_objects()\n "
770772 """
771773
772- return data.replace(' .', np.nan).fillna(impute_values).apply(pd.to_numeric, errors='ignore')
774+ # Specify downcasting behavior for pandas 2.x to avoid warnings
775+ if int(pd.__version__.split('.')[0]) == 2:
776+ pd.set_option('future.no_silent_downcasting', True)
777+ return data.replace(r'^\s*\.$', np.nan, regex=True).fillna(impute_values).infer_objects()
773778 """
774779
775780 # TODO: Needs unit test
You can’t perform that action at this time.
0 commit comments