From 7c94a98dffe40770d3eeba82ac364d3b1502e90f Mon Sep 17 00:00:00 2001 From: mrjleo Date: Fri, 18 Oct 2024 17:43:15 +0200 Subject: [PATCH] set orig_index in Index.__call__ to avoid pandas SettingWithCopyWarning --- fast_forward/index/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fast_forward/index/__init__.py b/fast_forward/index/__init__.py index 0a8e090..2e7ab75 100644 --- a/fast_forward/index/__init__.py +++ b/fast_forward/index/__init__.py @@ -369,9 +369,6 @@ def _early_stopping( Returns: pd.DataFrame: Data frame with computed scores. """ - # early stopping splits the data frame, hence we need to keep track of the original index - df["orig_index"] = df.index - # data frame for computed scores scores_so_far = None @@ -464,6 +461,9 @@ def __call__( query_df["q_no"] = query_df.index df_with_q_no = ranking._df.merge(query_df, on="q_id", suffixes=[None, "_"]) + # early stopping splits the data frame, hence we need to keep track of the original index + df_with_q_no["orig_index"] = df_with_q_no.index + # batch encode queries query_vectors = self.encode_queries(list(query_df["query"]))