Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1300,9 +1300,11 @@ def analisis_comparativo_desempleo():
|
|
1300 |
|
1301 |
def generar_analisis_global():
|
1302 |
figs = []
|
|
|
|
|
1303 |
figs.append(analisis_comparativo_desempleo())
|
1304 |
|
1305 |
-
# Gr谩fico de ingresos
|
1306 |
datos_ingresos = []
|
1307 |
for ciudad, data in cities_data.items():
|
1308 |
nombre = normalizar_nombres_ciudades(ciudad)
|
@@ -1314,14 +1316,24 @@ def generar_analisis_global():
|
|
1314 |
|
1315 |
if datos_ingresos:
|
1316 |
df_ingresos = pd.concat(datos_ingresos)
|
1317 |
-
fig_ingresos = px.line(df_ingresos,
|
1318 |
-
|
1319 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1320 |
figs.append(fig_ingresos)
|
1321 |
else:
|
1322 |
figs.append(go.Figure())
|
1323 |
|
1324 |
-
# Gr谩fico de brecha
|
1325 |
datos_brecha = []
|
1326 |
for ciudad, data in cities_data.items():
|
1327 |
nombre = normalizar_nombres_ciudades(ciudad)
|
@@ -1334,10 +1346,24 @@ def generar_analisis_global():
|
|
1334 |
|
1335 |
if datos_brecha:
|
1336 |
df_brecha = pd.concat(datos_brecha)
|
1337 |
-
fig_brecha = px.bar(df_brecha,
|
1338 |
-
|
1339 |
-
|
1340 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1341 |
figs.append(fig_brecha)
|
1342 |
else:
|
1343 |
figs.append(go.Figure())
|
@@ -1365,8 +1391,12 @@ def actualizar_graficos(ciudad):
|
|
1365 |
), "Brecha Salarial", "%", ".1f")
|
1366 |
]
|
1367 |
|
1368 |
-
with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue"), css="
|
1369 |
-
|
|
|
|
|
|
|
|
|
1370 |
|
1371 |
with gr.Row():
|
1372 |
ciudad = gr.Dropdown(
|
@@ -1376,24 +1406,29 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue"), css=".gradio-container
|
|
1376 |
interactive=True
|
1377 |
)
|
1378 |
|
1379 |
-
with gr.Tab("An谩lisis Ciudad"):
|
1380 |
with gr.Row():
|
1381 |
desempleo_plot = Plot(label="Tasa de Desempleo")
|
|
|
1382 |
ingresos_plot = Plot(label="Ingresos Promedio")
|
1383 |
with gr.Row():
|
1384 |
informalidad_plot = Plot(label="Tasa de Informalidad")
|
|
|
1385 |
actividad_plot = Plot(label="Tasa de Actividad")
|
1386 |
with gr.Row():
|
1387 |
radar_plot = Plot(label="Radar de Indicadores")
|
|
|
1388 |
brecha_plot = Plot(label="Brecha Salarial")
|
1389 |
|
1390 |
with gr.Tab("An谩lisis Comparativo"):
|
1391 |
with gr.Row():
|
1392 |
global_desempleo = Plot(label="Ranking de Desempleo")
|
1393 |
with gr.Row():
|
1394 |
-
global_ingresos = Plot(label="
|
1395 |
-
|
1396 |
-
|
|
|
|
|
1397 |
|
1398 |
# Eventos
|
1399 |
ciudad.change(
|
|
|
1300 |
|
1301 |
def generar_analisis_global():
|
1302 |
figs = []
|
1303 |
+
|
1304 |
+
# Gr谩fico comparativo de desempleo
|
1305 |
figs.append(analisis_comparativo_desempleo())
|
1306 |
|
1307 |
+
# Gr谩fico de tendencia de ingresos (full width)
|
1308 |
datos_ingresos = []
|
1309 |
for ciudad, data in cities_data.items():
|
1310 |
nombre = normalizar_nombres_ciudades(ciudad)
|
|
|
1316 |
|
1317 |
if datos_ingresos:
|
1318 |
df_ingresos = pd.concat(datos_ingresos)
|
1319 |
+
fig_ingresos = px.line(df_ingresos,
|
1320 |
+
x='Periodo',
|
1321 |
+
y='Total',
|
1322 |
+
color='Ciudad',
|
1323 |
+
title='<b>Evoluci贸n Hist贸rica de Ingresos Promedio por Ciudad</b>',
|
1324 |
+
markers=True,
|
1325 |
+
height=600)
|
1326 |
+
fig_ingresos.update_layout(
|
1327 |
+
xaxis_title='Periodo',
|
1328 |
+
yaxis_title='Ingresos (Soles)',
|
1329 |
+
legend=dict(title='Ciudades'),
|
1330 |
+
margin=dict(l=50, r=50, t=80, b=50)
|
1331 |
+
)
|
1332 |
figs.append(fig_ingresos)
|
1333 |
else:
|
1334 |
figs.append(go.Figure())
|
1335 |
|
1336 |
+
# Gr谩fico de brecha salarial (full width)
|
1337 |
datos_brecha = []
|
1338 |
for ciudad, data in cities_data.items():
|
1339 |
nombre = normalizar_nombres_ciudades(ciudad)
|
|
|
1346 |
|
1347 |
if datos_brecha:
|
1348 |
df_brecha = pd.concat(datos_brecha)
|
1349 |
+
fig_brecha = px.bar(df_brecha,
|
1350 |
+
x='Ciudad',
|
1351 |
+
y='Brecha',
|
1352 |
+
color='Brecha',
|
1353 |
+
title='<b>Comparaci贸n de Brecha Salarial por Ciudad</b>',
|
1354 |
+
text_auto='.1f%',
|
1355 |
+
height=600,
|
1356 |
+
color_continuous_scale='Viridis')
|
1357 |
+
|
1358 |
+
fig_brecha.update_layout(
|
1359 |
+
xaxis_title='Ciudad',
|
1360 |
+
yaxis_title='Brecha Salarial (%)',
|
1361 |
+
coloraxis_showscale=False,
|
1362 |
+
xaxis={'categoryorder':'total descending'},
|
1363 |
+
margin=dict(l=50, r=50, t=80, b=150),
|
1364 |
+
uniformtext_minsize=8,
|
1365 |
+
uniformtext_mode='hide'
|
1366 |
+
)
|
1367 |
figs.append(fig_brecha)
|
1368 |
else:
|
1369 |
figs.append(go.Figure())
|
|
|
1391 |
), "Brecha Salarial", "%", ".1f")
|
1392 |
]
|
1393 |
|
1394 |
+
with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue"), css="""
|
1395 |
+
.gradio-container {background-color: #f8f9fa}
|
1396 |
+
.plot-container {margin: 20px 0}
|
1397 |
+
""") as app:
|
1398 |
+
|
1399 |
+
gr.Markdown("# 馃搳 Dashboard Anal铆tico del Mercado Laboral Peruano")
|
1400 |
|
1401 |
with gr.Row():
|
1402 |
ciudad = gr.Dropdown(
|
|
|
1406 |
interactive=True
|
1407 |
)
|
1408 |
|
1409 |
+
with gr.Tab("An谩lisis por Ciudad"):
|
1410 |
with gr.Row():
|
1411 |
desempleo_plot = Plot(label="Tasa de Desempleo")
|
1412 |
+
with gr.Row():
|
1413 |
ingresos_plot = Plot(label="Ingresos Promedio")
|
1414 |
with gr.Row():
|
1415 |
informalidad_plot = Plot(label="Tasa de Informalidad")
|
1416 |
+
with gr.Row():
|
1417 |
actividad_plot = Plot(label="Tasa de Actividad")
|
1418 |
with gr.Row():
|
1419 |
radar_plot = Plot(label="Radar de Indicadores")
|
1420 |
+
with gr.Row():
|
1421 |
brecha_plot = Plot(label="Brecha Salarial")
|
1422 |
|
1423 |
with gr.Tab("An谩lisis Comparativo"):
|
1424 |
with gr.Row():
|
1425 |
global_desempleo = Plot(label="Ranking de Desempleo")
|
1426 |
with gr.Row():
|
1427 |
+
global_ingresos = Plot(label="Evoluci贸n de Ingresos")
|
1428 |
+
with gr.Row():
|
1429 |
+
global_brecha = Plot(label="Comparaci贸n de Brecha Salarial")
|
1430 |
+
with gr.Row():
|
1431 |
+
global_btn = gr.Button("Actualizar Datos", variant="primary")
|
1432 |
|
1433 |
# Eventos
|
1434 |
ciudad.change(
|