Spaces:
Running
Running
Commit
•
f61bdc6
1
Parent(s):
ed3e5cb
Update app.py (#11)
Browse files- Update app.py (876f50aca38079cd8de848ac48e72005e8960832)
Co-authored-by: Polina Shishenkova <PolinaShishenkova@users.noreply.huggingface.co>
app.py
CHANGED
@@ -83,6 +83,8 @@ def main():
|
|
83 |
# Выбор таблицы для отображения с помощью selectbox
|
84 |
selected_table = st.selectbox("Выберите таблицу", list(tables.keys()))
|
85 |
if selected_table == 'Комментарии':
|
|
|
|
|
86 |
# post_filter_value = st.text_input("Введите ID постов (разделите их запятой)", key='post_ids_input')
|
87 |
# post_ids = [int(post_id.strip()) for post_id in post_ids_input.split(', ') if post_id.strip()] if post_ids_input else []
|
88 |
|
@@ -93,6 +95,10 @@ def main():
|
|
93 |
country_filter = st.sidebar.multiselect("Фильтр по стране", tables[selected_table]['Country'].unique(), default=[])
|
94 |
city_filter = st.sidebar.multiselect("Фильтр по городу", tables[selected_table]['City'].unique(), default=[])
|
95 |
sex_filter = st.sidebar.multiselect("Фильтр по полу", tables[selected_table]['Sex'].unique(), default=[])
|
|
|
|
|
|
|
|
|
96 |
# post_filter_value = st.text_area("Поиск всех комментариев к определенным постам (столбец 'Пост')")
|
97 |
|
98 |
# date_type = st.radio("Выберите тип фильтрации по дате", ["Диапазон дат", "Конкретная дата", 'Все'], index=2)
|
@@ -118,7 +124,8 @@ def main():
|
|
118 |
filtered_data = filtered_data[filtered_data['Country'].isin(country_filter)]
|
119 |
if sex_filter:
|
120 |
filtered_data = filtered_data[filtered_data['Sex'].isin(sex_filter)]
|
121 |
-
|
|
|
122 |
# post_filter_value = st.number_input("Введите ID постов (столбец 'Пост') (разделите их запятой)",min_value=0)
|
123 |
# if post_filter_value:
|
124 |
# filtered_data = filtered_data[filtered_data['Пост'] == post_filter_value]
|
@@ -219,7 +226,9 @@ def main():
|
|
219 |
country_filter = st.sidebar.multiselect("Фильтр по стране", tables[selected_table]['Country'].unique(), default=[],key = 'user_country')
|
220 |
city_filter = st.sidebar.multiselect("Фильтр по городу", tables[selected_table]['City'].unique(), default=[],key = 'user_city')
|
221 |
sex_filter = st.sidebar.multiselect("Фильтр по полу", tables[selected_table]['Sex'].unique(), default=[],key = 'user_sex')
|
222 |
-
|
|
|
|
|
223 |
if st.button('🗺️ Показать карту географии подписчиков'):
|
224 |
st.write('Карта загружается...')
|
225 |
cities = tables[selected_table]['City'].unique()
|
@@ -256,7 +265,7 @@ def main():
|
|
256 |
filtered_data = filtered_data[filtered_data['Country'].isin(country_filter)]
|
257 |
if sex_filter:
|
258 |
filtered_data = filtered_data[filtered_data['Sex'].isin(sex_filter)]
|
259 |
-
if
|
260 |
filtered_data = filtered_data[(filtered_data['Age'] >= age_limits[0]) & (filtered_data['Age'] <= age_limits[1])]
|
261 |
filtered_data = filtered_data.reset_index(drop=True)
|
262 |
|
|
|
83 |
# Выбор таблицы для отображения с помощью selectbox
|
84 |
selected_table = st.selectbox("Выберите таблицу", list(tables.keys()))
|
85 |
if selected_table == 'Комментарии':
|
86 |
+
filtered_data = tables[selected_table]
|
87 |
+
filtered_data['Age'] = pd.to_numeric(filtered_data['Age'], errors='coerce')
|
88 |
# post_filter_value = st.text_input("Введите ID постов (разделите их запятой)", key='post_ids_input')
|
89 |
# post_ids = [int(post_id.strip()) for post_id in post_ids_input.split(', ') if post_id.strip()] if post_ids_input else []
|
90 |
|
|
|
95 |
country_filter = st.sidebar.multiselect("Фильтр по стране", tables[selected_table]['Country'].unique(), default=[])
|
96 |
city_filter = st.sidebar.multiselect("Фильтр по городу", tables[selected_table]['City'].unique(), default=[])
|
97 |
sex_filter = st.sidebar.multiselect("Фильтр по полу", tables[selected_table]['Sex'].unique(), default=[])
|
98 |
+
st.sidebar.subheader("Возраст пользователя")
|
99 |
+
check_age = st.sidebar.checkbox("Указать возраст пользователей", key="disabled")
|
100 |
+
if check_age:
|
101 |
+
age_limits = st.sidebar.slider("Выберите диапазон возраста пользователей", 0, 100, (int(np.min(filtered_data['Age'])), 70))
|
102 |
# post_filter_value = st.text_area("Поиск всех комментариев к определенным постам (столбец 'Пост')")
|
103 |
|
104 |
# date_type = st.radio("Выберите тип фильтрации по дате", ["Диапазон дат", "Конкретная дата", 'Все'], index=2)
|
|
|
124 |
filtered_data = filtered_data[filtered_data['Country'].isin(country_filter)]
|
125 |
if sex_filter:
|
126 |
filtered_data = filtered_data[filtered_data['Sex'].isin(sex_filter)]
|
127 |
+
if check_age:
|
128 |
+
filtered_data = filtered_data[(filtered_data['Age'] >= age_limits[0]) & (filtered_data['Age'] <= age_limits[1])]
|
129 |
# post_filter_value = st.number_input("Введите ID постов (столбец 'Пост') (разделите их запятой)",min_value=0)
|
130 |
# if post_filter_value:
|
131 |
# filtered_data = filtered_data[filtered_data['Пост'] == post_filter_value]
|
|
|
226 |
country_filter = st.sidebar.multiselect("Фильтр по стране", tables[selected_table]['Country'].unique(), default=[],key = 'user_country')
|
227 |
city_filter = st.sidebar.multiselect("Фильтр по городу", tables[selected_table]['City'].unique(), default=[],key = 'user_city')
|
228 |
sex_filter = st.sidebar.multiselect("Фильтр по полу", tables[selected_table]['Sex'].unique(), default=[],key = 'user_sex')
|
229 |
+
check_age = st.sidebar.checkbox("Указать возраст пользователей", key="disabled")
|
230 |
+
if check_age:
|
231 |
+
age_limits = st.sidebar.slider("Выберите диапазон возраста пользователей", 0, 100, (int(np.min(filtered_data['Age'])), 70))
|
232 |
if st.button('🗺️ Показать карту географии подписчиков'):
|
233 |
st.write('Карта загружается...')
|
234 |
cities = tables[selected_table]['City'].unique()
|
|
|
265 |
filtered_data = filtered_data[filtered_data['Country'].isin(country_filter)]
|
266 |
if sex_filter:
|
267 |
filtered_data = filtered_data[filtered_data['Sex'].isin(sex_filter)]
|
268 |
+
if check_age:
|
269 |
filtered_data = filtered_data[(filtered_data['Age'] >= age_limits[0]) & (filtered_data['Age'] <= age_limits[1])]
|
270 |
filtered_data = filtered_data.reset_index(drop=True)
|
271 |
|