Skip to content

Commit

Permalink
set orig_index in Index.__call__ to avoid pandas SettingWithCopyWarning
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjleo committed Oct 18, 2024
1 parent 4308869 commit 7c94a98
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions fast_forward/index/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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"]))

Expand Down

0 comments on commit 7c94a98

Please sign in to comment.