Spaces:
Running
Running
fschwartzer
commited on
Update app.py
Browse files
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.
|
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 |
|