Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -41,27 +41,27 @@ def get_approaches(gender, generation, psychotype, approaches_df):
|
|
41 |
|
42 |
filters = []
|
43 |
for param_name, param_value in [('Пол', gender), ('Поколение', generation), ('Психотип', psychotype)]:
|
44 |
-
|
45 |
-
|
46 |
-
else:
|
47 |
filters.append(approaches_df[param_name].isnull() | (approaches_df[param_name].fillna('') == ''))
|
48 |
-
|
|
|
|
|
49 |
combined_filter = filters[0]
|
50 |
for f in filters[1:]:
|
51 |
combined_filter &= f
|
52 |
-
|
53 |
matching_rows = approaches_df[combined_filter]
|
54 |
if matching_rows.empty:
|
55 |
return "Подход не найден для выбранных параметров."
|
56 |
-
|
57 |
approach_list = []
|
58 |
for approaches in matching_rows['Подход']:
|
59 |
approach_names = [a.strip() for a in str(approaches).split(',')]
|
60 |
approach_list.extend(approach_names)
|
61 |
-
|
62 |
-
#
|
63 |
approach_list = list(set(approach_list))
|
64 |
-
|
65 |
selected_approaches_text_content = ', '.join(approach_list)
|
66 |
return selected_approaches_text_content
|
67 |
|
|
|
41 |
|
42 |
filters = []
|
43 |
for param_name, param_value in [('Пол', gender), ('Поколение', generation), ('Психотип', psychotype)]:
|
44 |
+
# Проверяем, если значение параметра "Не выбрано" или пустое
|
45 |
+
if not param_value or param_value == "Не выбрано":
|
|
|
46 |
filters.append(approaches_df[param_name].isnull() | (approaches_df[param_name].fillna('') == ''))
|
47 |
+
else:
|
48 |
+
filters.append(approaches_df[param_name].fillna('') == param_value)
|
49 |
+
|
50 |
combined_filter = filters[0]
|
51 |
for f in filters[1:]:
|
52 |
combined_filter &= f
|
53 |
+
|
54 |
matching_rows = approaches_df[combined_filter]
|
55 |
if matching_rows.empty:
|
56 |
return "Подход не найден для выбранных параметров."
|
57 |
+
|
58 |
approach_list = []
|
59 |
for approaches in matching_rows['Подход']:
|
60 |
approach_names = [a.strip() for a in str(approaches).split(',')]
|
61 |
approach_list.extend(approach_names)
|
62 |
+
|
63 |
+
# Удаляем дубликаты
|
64 |
approach_list = list(set(approach_list))
|
|
|
65 |
selected_approaches_text_content = ', '.join(approach_list)
|
66 |
return selected_approaches_text_content
|
67 |
|