fschwartzer commited on
Commit
ef37c27
1 Parent(s): 7413ee9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -29,14 +29,14 @@ def filter_dataframe(df, user_question, threshold=80):
29
  user_question = remove_stopwords(user_question) # Remove stopwords
30
  question_words = user_question.split()
31
 
32
- mask = pd.Series([False] * len(df))
33
 
34
  for column in df.columns:
35
  for word in question_words:
36
  # Apply RapidFuzz fuzzy matching on the column
37
  matches = process.extract(word, df[column], scorer=fuzz.token_sort_ratio, limit=None)
38
  match_indices = [match[2] for match in matches if match[1] >= threshold]
39
- mask.iloc[match_indices] = True
40
 
41
  filtered_df = df[mask]
42
 
 
29
  user_question = remove_stopwords(user_question) # Remove stopwords
30
  question_words = user_question.split()
31
 
32
+ mask = pd.Series([False] * len(df), index=df.index)
33
 
34
  for column in df.columns:
35
  for word in question_words:
36
  # Apply RapidFuzz fuzzy matching on the column
37
  matches = process.extract(word, df[column], scorer=fuzz.token_sort_ratio, limit=None)
38
  match_indices = [match[2] for match in matches if match[1] >= threshold]
39
+ mask.loc[match_indices] = True # Ensure the mask is aligned with the DataFrame index
40
 
41
  filtered_df = df[mask]
42