C2MV commited on
Commit
73a1074
·
verified ·
1 Parent(s): 3a57781

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -25
app.py CHANGED
@@ -5,7 +5,7 @@ import plotly.graph_objects as go
5
  import gradio as gr
6
  from gradio.components import Plot
7
 
8
- #DATA
9
 
10
  cities_data = {
11
  'Abancay': {
@@ -1151,7 +1151,7 @@ cities_data = {
1151
  }
1152
 
1153
 
1154
- #DATA
1155
 
1156
  COLORES = {
1157
  'Total': '#2C3E50',
@@ -1255,11 +1255,12 @@ def crear_radar_plot(dfs):
1255
  fig.update_layout(
1256
  polar=dict(
1257
  radialaxis=dict(visible=True, range=[0, 100], tickfont=dict(size=12)),
1258
- angularaxis=dict(rotation=90, direction='clockwise', tickfont=dict(size=14)),
 
1259
  title=dict(text='Radar de Indicadores Laborales', x=0.5, font=dict(size=20)),
1260
  showlegend=False,
1261
  height=500
1262
- ))
1263
 
1264
  return fig
1265
 
@@ -1343,6 +1344,27 @@ def generar_analisis_global():
1343
 
1344
  return figs
1345
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1346
  with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue"), css=".gradio-container {background-color: white}") as app:
1347
  gr.Markdown("# 📊 Dashboard Analítico del Mercado Laboral")
1348
 
@@ -1386,25 +1408,4 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue"), css=".gradio-container
1386
  outputs=[global_desempleo, global_ingresos, global_brecha]
1387
  )
1388
 
1389
- def actualizar_graficos(ciudad):
1390
- data = cities_data[ciudad]
1391
-
1392
- dfs = {
1393
- 'desempleo': procesar_dataframe(data['desempleo_trimestral'], ["Trimestre", "Total", "Hombres", "Mujeres"]),
1394
- 'ingresos': procesar_dataframe(data['ingresos_periodo'], ["Periodo", "Total", "Hombres", "Mujeres"]),
1395
- 'informal': procesar_dataframe(data['informal_periodo'], ["Periodo", "Total", "Hombres", "Mujeres"]),
1396
- 'actividad': procesar_dataframe(data['actividad_trimestral'], ["Trimestre", "Total", "Hombres", "Mujeres"])
1397
- }
1398
-
1399
- return [
1400
- crear_grafico_lineas(dfs['desempleo'], "Tasa de Desempleo", "%", ".1f"),
1401
- crear_grafico_lineas(dfs['ingresos'], "Ingresos Promedio", "Soles", ".0f"),
1402
- crear_grafico_lineas(dfs['informal'], "Tasa de Informalidad", "%", ".1f"),
1403
- crear_grafico_lineas(dfs['actividad'], "Tasa de Actividad", "%", ".1f"),
1404
- crear_radar_plot(dfs),
1405
- crear_grafico_lineas(dfs['ingresos'].assign(
1406
- Brecha=lambda x: (x['Hombres'] - x['Mujeres']) / x['Hombres'].replace(0, np.nan) * 100
1407
- ), "Brecha Salarial", "%", ".1f")
1408
- ]
1409
-
1410
  app.launch(debug=True)
 
5
  import gradio as gr
6
  from gradio.components import Plot
7
 
8
+ #DATOS
9
 
10
  cities_data = {
11
  'Abancay': {
 
1151
  }
1152
 
1153
 
1154
+ #DATOS
1155
 
1156
  COLORES = {
1157
  'Total': '#2C3E50',
 
1255
  fig.update_layout(
1256
  polar=dict(
1257
  radialaxis=dict(visible=True, range=[0, 100], tickfont=dict(size=12)),
1258
+ angularaxis=dict(rotation=90, direction='clockwise', tickfont=dict(size=14))
1259
+ ),
1260
  title=dict(text='Radar de Indicadores Laborales', x=0.5, font=dict(size=20)),
1261
  showlegend=False,
1262
  height=500
1263
+ )
1264
 
1265
  return fig
1266
 
 
1344
 
1345
  return figs
1346
 
1347
+ def actualizar_graficos(ciudad):
1348
+ data = cities_data[ciudad]
1349
+
1350
+ dfs = {
1351
+ 'desempleo': procesar_dataframe(data['desempleo_trimestral'], ["Trimestre", "Total", "Hombres", "Mujeres"]),
1352
+ 'ingresos': procesar_dataframe(data['ingresos_periodo'], ["Periodo", "Total", "Hombres", "Mujeres"]),
1353
+ 'informal': procesar_dataframe(data['informal_periodo'], ["Periodo", "Total", "Hombres", "Mujeres"]),
1354
+ 'actividad': procesar_dataframe(data['actividad_trimestral'], ["Trimestre", "Total", "Hombres", "Mujeres"])
1355
+ }
1356
+
1357
+ return [
1358
+ crear_grafico_lineas(dfs['desempleo'], "Tasa de Desempleo", "%", ".1f"),
1359
+ crear_grafico_lineas(dfs['ingresos'], "Ingresos Promedio", "Soles", ".0f"),
1360
+ crear_grafico_lineas(dfs['informal'], "Tasa de Informalidad", "%", ".1f"),
1361
+ crear_grafico_lineas(dfs['actividad'], "Tasa de Actividad", "%", ".1f"),
1362
+ crear_radar_plot(dfs),
1363
+ crear_grafico_lineas(dfs['ingresos'].assign(
1364
+ Brecha=lambda x: (x['Hombres'] - x['Mujeres']) / x['Hombres'].replace(0, np.nan) * 100
1365
+ ), "Brecha Salarial", "%", ".1f")
1366
+ ]
1367
+
1368
  with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue"), css=".gradio-container {background-color: white}") as app:
1369
  gr.Markdown("# 📊 Dashboard Analítico del Mercado Laboral")
1370
 
 
1408
  outputs=[global_desempleo, global_ingresos, global_brecha]
1409
  )
1410
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1411
  app.launch(debug=True)