From 05133dce8215c1443897c0e40992e5312fefc24a Mon Sep 17 00:00:00 2001 From: Nico Matentzoglu Date: Fri, 8 Nov 2024 23:20:18 +0200 Subject: [PATCH] Suppress ChainedAssignmentError 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. --- 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)