Update modules/dados.py
Browse files- modules/dados.py +18 -18
modules/dados.py
CHANGED
|
@@ -187,15 +187,17 @@ bairro_list = ["Todos"] + sorted(df['Bairro'].dropna().unique().tolist())
|
|
| 187 |
fonte_list = ["Todos"] + sorted(df['Fonte'].dropna().unique().tolist())
|
| 188 |
|
| 189 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 190 |
def dados_tab():
|
| 191 |
with gr.Tab("Pesquisar Dados"):
|
| 192 |
toggle_filters = gr.Checkbox(label="Exibir Campos de Pesquisa", value=True)
|
| 193 |
-
|
| 194 |
with gr.Row(visible=True) as filters:
|
| 195 |
tipo_filter = gr.Dropdown(label="Selecione os Tipos de Imóvel", choices=property_types, value=["Todos"], multiselect=True)
|
| 196 |
bairro_filter = gr.Dropdown(label="Selecione os Bairros", choices=bairro_list, value=["Todos"], multiselect=True)
|
| 197 |
fonte_filter = gr.Dropdown(label="Selecione a Fonte", choices=fonte_list, value=["Todos"], multiselect=True)
|
| 198 |
-
|
| 199 |
with gr.Row(visible=True) as area_filters:
|
| 200 |
min_atotal = gr.Number(label="Área Total Mínima", value=None)
|
| 201 |
max_atotal = gr.Number(label="Área Total Máxima", value=None)
|
|
@@ -203,56 +205,54 @@ def dados_tab():
|
|
| 203 |
max_apriv = gr.Number(label="Área Privativa Máxima", value=None)
|
| 204 |
min_ater = gr.Number(label="Área Terreno Mínima", value=None)
|
| 205 |
max_ater = gr.Number(label="Área Terreno Máxima", value=None)
|
| 206 |
-
|
| 207 |
with gr.Row(visible=True) as date_filters:
|
| 208 |
-
min_date = gr.Textbox(label="Data Inicial (AAAA-MM-DD)", value=
|
| 209 |
-
max_date = gr.Textbox(label="Data Final (AAAA-MM-DD)", value=
|
| 210 |
|
| 211 |
with gr.Row(visible=True) as address_filters:
|
| 212 |
address_input = gr.Textbox(label="Endereço (Opcional)")
|
| 213 |
radius_input = gr.Number(label="Raio em metros (Opcional)")
|
| 214 |
-
|
| 215 |
with gr.Row():
|
| 216 |
search_button = gr.Button("Pesquisar")
|
| 217 |
clear_button = gr.Button("Limpar")
|
| 218 |
-
|
| 219 |
map_output = gr.Plot()
|
| 220 |
stats_output = gr.Textbox(lines=4, label="Estatísticas")
|
| 221 |
filtered_df_output = gr.DataFrame(label="Dados Filtrados")
|
| 222 |
download_output = gr.File(label="Baixar Dados Filtrados")
|
| 223 |
|
| 224 |
def clear_action():
|
| 225 |
-
return (["Todos"], ["Todos"], ["Todos"], None, None, None, None, None, None,
|
| 226 |
|
| 227 |
toggle_filters.change(
|
| 228 |
lambda show: (
|
| 229 |
-
gr.update(visible=show),
|
| 230 |
-
gr.update(visible=show),
|
| 231 |
gr.update(visible=show),
|
| 232 |
-
gr.update(visible=show)
|
| 233 |
-
|
| 234 |
-
|
|
|
|
|
|
|
| 235 |
outputs=[filters, area_filters, address_filters, date_filters]
|
| 236 |
)
|
| 237 |
|
| 238 |
-
|
| 239 |
search_button.click(
|
| 240 |
unified_action,
|
| 241 |
-
inputs=[tipo_filter, bairro_filter, fonte_filter, min_atotal, max_atotal, min_apriv, max_apriv,
|
| 242 |
min_ater, max_ater, min_date, max_date, address_input, radius_input],
|
| 243 |
outputs=[map_output, stats_output, filtered_df_output, download_output]
|
| 244 |
)
|
| 245 |
|
| 246 |
clear_button.click(
|
| 247 |
-
clear_action,
|
| 248 |
-
outputs=[tipo_filter, bairro_filter, fonte_filter, min_atotal, max_atotal, min_apriv, max_apriv,
|
| 249 |
-
min_ater, max_ater, min_date, max_date, address_input, radius_input,
|
| 250 |
map_output, stats_output, filtered_df_output, download_output]
|
| 251 |
)
|
| 252 |
|
| 253 |
return locals(), filtered_df_output
|
| 254 |
|
| 255 |
|
|
|
|
| 256 |
### implementar o KNN
|
| 257 |
### Arrumar a questão de que somente clicando no botão "Limpar" é possível acionar os filtros
|
| 258 |
### Filtro por data
|
|
|
|
| 187 |
fonte_list = ["Todos"] + sorted(df['Fonte'].dropna().unique().tolist())
|
| 188 |
|
| 189 |
|
| 190 |
+
# Encontrar a menor e a maior data no DataFrame
|
| 191 |
+
min_data = df['Data'].min()
|
| 192 |
+
max_data = df['Data'].max()
|
| 193 |
+
|
| 194 |
def dados_tab():
|
| 195 |
with gr.Tab("Pesquisar Dados"):
|
| 196 |
toggle_filters = gr.Checkbox(label="Exibir Campos de Pesquisa", value=True)
|
|
|
|
| 197 |
with gr.Row(visible=True) as filters:
|
| 198 |
tipo_filter = gr.Dropdown(label="Selecione os Tipos de Imóvel", choices=property_types, value=["Todos"], multiselect=True)
|
| 199 |
bairro_filter = gr.Dropdown(label="Selecione os Bairros", choices=bairro_list, value=["Todos"], multiselect=True)
|
| 200 |
fonte_filter = gr.Dropdown(label="Selecione a Fonte", choices=fonte_list, value=["Todos"], multiselect=True)
|
|
|
|
| 201 |
with gr.Row(visible=True) as area_filters:
|
| 202 |
min_atotal = gr.Number(label="Área Total Mínima", value=None)
|
| 203 |
max_atotal = gr.Number(label="Área Total Máxima", value=None)
|
|
|
|
| 205 |
max_apriv = gr.Number(label="Área Privativa Máxima", value=None)
|
| 206 |
min_ater = gr.Number(label="Área Terreno Mínima", value=None)
|
| 207 |
max_ater = gr.Number(label="Área Terreno Máxima", value=None)
|
| 208 |
+
|
| 209 |
with gr.Row(visible=True) as date_filters:
|
| 210 |
+
min_date = gr.Textbox(label="Data Inicial (AAAA-MM-DD)", value=min_data.strftime('%Y-%m-%d'))
|
| 211 |
+
max_date = gr.Textbox(label="Data Final (AAAA-MM-DD)", value=max_data.strftime('%Y-%m-%d'))
|
| 212 |
|
| 213 |
with gr.Row(visible=True) as address_filters:
|
| 214 |
address_input = gr.Textbox(label="Endereço (Opcional)")
|
| 215 |
radius_input = gr.Number(label="Raio em metros (Opcional)")
|
|
|
|
| 216 |
with gr.Row():
|
| 217 |
search_button = gr.Button("Pesquisar")
|
| 218 |
clear_button = gr.Button("Limpar")
|
|
|
|
| 219 |
map_output = gr.Plot()
|
| 220 |
stats_output = gr.Textbox(lines=4, label="Estatísticas")
|
| 221 |
filtered_df_output = gr.DataFrame(label="Dados Filtrados")
|
| 222 |
download_output = gr.File(label="Baixar Dados Filtrados")
|
| 223 |
|
| 224 |
def clear_action():
|
| 225 |
+
return (["Todos"], ["Todos"], ["Todos"], None, None, None, None, None, None, min_data.strftime('%Y-%m-%d'), max_data.strftime('%Y-%m-%d'), "", None, None, "", pd.DataFrame(), None)
|
| 226 |
|
| 227 |
toggle_filters.change(
|
| 228 |
lambda show: (
|
|
|
|
|
|
|
| 229 |
gr.update(visible=show),
|
| 230 |
+
gr.update(visible=show),
|
| 231 |
+
gr.update(visible=show),
|
| 232 |
+
gr.update(visible=show)
|
| 233 |
+
),
|
| 234 |
+
inputs=[toggle_filters],
|
| 235 |
outputs=[filters, area_filters, address_filters, date_filters]
|
| 236 |
)
|
| 237 |
|
|
|
|
| 238 |
search_button.click(
|
| 239 |
unified_action,
|
| 240 |
+
inputs=[tipo_filter, bairro_filter, fonte_filter, min_atotal, max_atotal, min_apriv, max_apriv,
|
| 241 |
min_ater, max_ater, min_date, max_date, address_input, radius_input],
|
| 242 |
outputs=[map_output, stats_output, filtered_df_output, download_output]
|
| 243 |
)
|
| 244 |
|
| 245 |
clear_button.click(
|
| 246 |
+
clear_action,
|
| 247 |
+
outputs=[tipo_filter, bairro_filter, fonte_filter, min_atotal, max_atotal, min_apriv, max_apriv,
|
| 248 |
+
min_ater, max_ater, min_date, max_date, address_input, radius_input,
|
| 249 |
map_output, stats_output, filtered_df_output, download_output]
|
| 250 |
)
|
| 251 |
|
| 252 |
return locals(), filtered_df_output
|
| 253 |
|
| 254 |
|
| 255 |
+
|
| 256 |
### implementar o KNN
|
| 257 |
### Arrumar a questão de que somente clicando no botão "Limpar" é possível acionar os filtros
|
| 258 |
### Filtro por data
|