From e2d4437feef4f57d25a507edb1fee392e0c14f76 Mon Sep 17 00:00:00 2001 From: Jerome Dockes Date: Fri, 5 Jul 2024 12:00:05 +0200 Subject: [PATCH] no_silent_downcasting doesn't exist in old pandas --- skrub/_dataframe/_common.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/skrub/_dataframe/_common.py b/skrub/_dataframe/_common.py index ce223c2f2..2d85cbcd6 100644 --- a/skrub/_dataframe/_common.py +++ b/skrub/_dataframe/_common.py @@ -706,8 +706,7 @@ def _to_string_pandas(col): return col if not is_na.any(): return col - with pd.option_context("future.no_silent_downcasting", True): - return col.fillna(np.nan) + return _fill_nulls_pandas(col, np.nan) @to_string.specialize("polars", argument_type="Column") @@ -1025,6 +1024,8 @@ def fill_nulls(obj, value): @fill_nulls.specialize("pandas") def _fill_nulls_pandas(obj, value): + if parse_version(pd.__version__) < parse_version("2.2.0"): + return obj.fillna(value) with pd.option_context("future.no_silent_downcasting", True): return obj.fillna(value)