From 68917a0009ab9445202122381b2f190924efe3d5 Mon Sep 17 00:00:00 2001 From: Nico Matentzoglu Date: Fri, 8 Nov 2024 23:38:48 +0200 Subject: [PATCH] Fix ChainedAssignmentError in from_sssom_dataframe Warning: ChainedAssignmentError: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method. When using the Copy-on-Write mode, such inplace method never works to update the original DataFrame or Series, because the intermediate object on which we are setting values always behaves as a copy. I just to just not use "inplace" here and the warning does not happen. --- src/sssom/parsers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sssom/parsers.py b/src/sssom/parsers.py index c2348fe3..98292943 100644 --- a/src/sssom/parsers.py +++ b/src/sssom/parsers.py @@ -425,7 +425,7 @@ def from_sssom_dataframe( # This is to address: A value is trying to be set on a copy of a slice from a DataFrame if CONFIDENCE in df.columns: df2 = df.copy() - df2[CONFIDENCE].replace(r"^\s*$", np.nan, regex=True, inplace=True) + df2[CONFIDENCE] = df2[CONFIDENCE].replace(r"^\s*$", np.nan, regex=True) df = df2 mapping_set = _get_mapping_set_from_df(df=df, meta=meta)