C2MV commited on
Commit
1340e48
·
verified ·
1 Parent(s): eef6991

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -9
app.py CHANGED
@@ -1153,8 +1153,6 @@ cities_data = {
1153
 
1154
  #DATOS
1155
 
1156
-
1157
-
1158
  COLORES = {
1159
  'Total': '#2C3E50',
1160
  'Hombres': '#3498DB',
@@ -1187,7 +1185,7 @@ def procesar_dataframe(df, columnas):
1187
  df_procesado[col] = pd.to_numeric(df_procesado[col], errors='coerce')
1188
  return df_procesado.dropna(how='all')
1189
 
1190
- def crear_grafico_lineas(df, titulo, eje_y, color=None, formato=None):
1191
  fig = go.Figure()
1192
 
1193
  for columna in ['Total', 'Hombres', 'Mujeres']:
@@ -1197,7 +1195,7 @@ def crear_grafico_lineas(df, titulo, eje_y, color=None, formato=None):
1197
  y=df[columna],
1198
  name=columna,
1199
  mode='lines+markers',
1200
- line=dict(color=COLORES.get(columna, color),
1201
  marker=dict(size=8),
1202
  hovertemplate=f'<b>{columna}</b>: %{{y:{formato or ".2f"}}}<extra></extra>'
1203
  ))
@@ -1231,9 +1229,10 @@ def crear_radar_plot(dfs):
1231
  metricas['Informalidad'] = dfs['informal']['Total'].iloc[-1]
1232
  metricas['Actividad'] = dfs['actividad']['Total'].iloc[-1]
1233
  metricas['Brecha Salarial'] = ((dfs['ingresos']['Hombres'].iloc[-1] -
1234
- dfs['ingresos']['Mujeres'].iloc[-1]) / \
1235
- dfs['ingresos']['Hombres'].iloc[-1] * 100
1236
- except (KeyError, IndexError, ZeroDivisionError):
 
1237
  return go.Figure()
1238
 
1239
  categories = list(metricas.keys())
@@ -1255,11 +1254,13 @@ def crear_radar_plot(dfs):
1255
  radialaxis=dict(
1256
  visible=True,
1257
  range=[0, 100],
1258
- tickfont=dict(size=12),
 
1259
  angularaxis=dict(
1260
  rotation=90,
1261
  direction='clockwise',
1262
- tickfont=dict(size=14))
 
1263
  ),
1264
  title=dict(text='Radar de Indicadores Laborales', x=0.5, font=dict(size=20)),
1265
  showlegend=False,
 
1153
 
1154
  #DATOS
1155
 
 
 
1156
  COLORES = {
1157
  'Total': '#2C3E50',
1158
  'Hombres': '#3498DB',
 
1185
  df_procesado[col] = pd.to_numeric(df_procesado[col], errors='coerce')
1186
  return df_procesado.dropna(how='all')
1187
 
1188
+ def crear_grafico_lineas(df, titulo, eje_y, formato=None):
1189
  fig = go.Figure()
1190
 
1191
  for columna in ['Total', 'Hombres', 'Mujeres']:
 
1195
  y=df[columna],
1196
  name=columna,
1197
  mode='lines+markers',
1198
+ line=dict(color=COLORES.get(columna, '#000000'),
1199
  marker=dict(size=8),
1200
  hovertemplate=f'<b>{columna}</b>: %{{y:{formato or ".2f"}}}<extra></extra>'
1201
  ))
 
1229
  metricas['Informalidad'] = dfs['informal']['Total'].iloc[-1]
1230
  metricas['Actividad'] = dfs['actividad']['Total'].iloc[-1]
1231
  metricas['Brecha Salarial'] = ((dfs['ingresos']['Hombres'].iloc[-1] -
1232
+ dfs['ingresos']['Mujeres'].iloc[-1]) /
1233
+ dfs['ingresos']['Hombres'].iloc[-1]) * 100
1234
+ except (KeyError, IndexError, ZeroDivisionError) as e:
1235
+ print(f"Error al generar radar plot: {str(e)}")
1236
  return go.Figure()
1237
 
1238
  categories = list(metricas.keys())
 
1254
  radialaxis=dict(
1255
  visible=True,
1256
  range=[0, 100],
1257
+ tickfont=dict(size=12)
1258
+ ),
1259
  angularaxis=dict(
1260
  rotation=90,
1261
  direction='clockwise',
1262
+ tickfont=dict(size=14)
1263
+ )
1264
  ),
1265
  title=dict(text='Radar de Indicadores Laborales', x=0.5, font=dict(size=20)),
1266
  showlegend=False,