C2MV commited on
Commit
2fe1f84
verified
1 Parent(s): 7e09939

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +193 -1516
app.py CHANGED
@@ -1,1175 +1,15 @@
1
  import pandas as pd
2
- import matplotlib.pyplot as plt
3
  import numpy as np
4
- import matplotlib.dates as mdates
5
- from datetime import datetime
6
- import seaborn as sns
7
  import gradio as gr
8
- from matplotlib.figure import Figure
9
-
10
-
11
-
12
- #DATA
13
-
14
- cities_data = {
15
- 'Abancay': {
16
- 'desempleo_trimestral': [
17
- ["2022-Q1", 6.7, 6.8, 6.6],
18
- ["2022-Q2", 3.7, None, None], # Dato de referencia
19
- ["2022-Q3", 2.3, 2.1, 2.6], # Dato de referencia
20
- ["2022-Q4", 2.8, 2.6, 3.1], # Dato de referencia
21
- ["2023-Q1", 6.0, 6.1, 5.9],
22
- ["2023-Q2", 4.9, 4.0, 6.0],
23
- ["2023-Q3", 5.8, 5.3, 6.5],
24
- ["2023-Q4", 4.5, 3.3, 5.9],
25
- ["2024-Q1", 7.2, 5.9, 8.8],
26
- ["2024-Q2", 8.1, 8.4, 7.8],
27
- ["2024-Q3", 6.7, 5.1, 8.5],
28
- ["2024-Q4", 6.1, 5.4, 6.8],
29
- ],
30
- 'ingresos_periodo': [
31
- ["2022-04/2023-03", 1913.0, 2212.5, 1548.0],
32
- ["2022-07/2023-06", 1898.4, 2203.9, 1523.8],
33
- ["2022-10/2023-09", 1903.2, 2179.2, 1564.3],
34
- ["2023-04/2024-03", 1949.7, 2224.0, 1609.3],
35
- ["2023-07/2024-06", 1999.4, 2276.3, 1658.1],
36
- ["2023-10/2024-09", 2044.2, 2341.5, 1679.2],
37
- ["2024", 2006.5, 2274.6, 1677.6],
38
- ],
39
- 'informal_periodo': [
40
- ["2022-04/2023-03", 68.2, 71.8, 65.1],
41
- ["2023", 66.8, 68.4, 65.5],
42
- ["2023-04/2024-03", None, None, None],
43
- ["2023-07/2024-06", None, None, None],
44
- ["2023-10/2024-09", None, None, None],
45
- ["2024", None, None, None],
46
-
47
- ],
48
- 'actividad_trimestral': [
49
- ["2023-Q3", 73.1, 79.7, 66.4],
50
- ["2024-Q3", 71.9, 76.7, 67.1],
51
- ],
52
- 'poblacion_ocupada': [
53
- ["2022-Q1", 42.5, 23.2, 19.3],
54
- ["2022-Q2", 43.1, 22.9, 20.1],
55
- ["2022-Q3", 47.6, 25.4, 22.2],
56
- ["2023-Q1", 43.6, 23.7, 20.0],
57
- ["2023-Q2", 44.1, 24.0, 20.2],
58
- ["2023-Q3", 46.6, 25.6, 21.1],
59
- ["2024-Q1", 43.4, 24.5, 18.8],
60
- ["2024-Q2", 45.5, 24.6, 20.9],
61
- ["2024-Q3", 46.5, 25.2, 21.3],
62
- ]
63
- },
64
- 'Arequipa': {
65
- 'desempleo_trimestral': [
66
- ["2022-Q1", 9.3, 8.0, 10.2],
67
- ["2022-Q2", 4.6, None, None],
68
- ["2022-Q3", 5.0, None, None],
69
- ["2022-Q4", 4.7, None, None],
70
- ["2023-Q1", 9.0, 8.0, 10.2],
71
- ["2023-Q2", 7.1, 6.4, 8.1],
72
- ["2023-Q3", 7.9, 6.1, 10.0],
73
- ["2023-Q4", 7.1, 6.2, 8.2],
74
- ["2024-Q1", 10.1, 8.9, 11.5],
75
- ["2024-Q2", 7.9, 7.4, 8.5],
76
- ["2024-Q3", 8.0, 6.2, 10.2],
77
- ["2024-Q4", 6.3, 5.4, 7.4],
78
- ],
79
- 'ingresos_periodo': [
80
- ["2022-04/2023-03", 2136.2, 2538.1, 1638.5],
81
- ["2022-07/2023-06", 2165.4, 2582.9, 1642.8],
82
- ["2023-04/2024-03", 2221.4, 2570.1, 1765.6],
83
- ["2023-07/2024-06", 2277.5, 2634.4, 1810.4],
84
- ["2023-10/2024-09", 2322.4, 2708.2, 1813.3],
85
- ["2024", 2298.6, 2698.8, 1773.9]
86
- ],
87
- 'informal_periodo': [
88
- ["2022-04/2023-03", 59.0, 57.3, 61.2],
89
- ["2022-07/2023-06", 58.3, 56.0, 61.1],
90
- ["2023", 56.0, 53.4, 59.2],
91
- ["2023-04/2024-03", 55.6, 53.2, 58.7],
92
- ["2023-07/2024-06", 55.1, 52.9, 57.9],
93
- ["2023-10/2024-09", 54.9, 52.7, 57.8],
94
- ["2024", None, None, None]
95
- ],
96
- 'actividad_trimestral': [
97
- ["2023-Q1",58.3,None, None],
98
- ["2023-Q2",58.7,None, None],
99
- ["2023-Q3",58.0,None, None],
100
- ["2024-Q1",56.3,None, None],
101
- ["2024-Q2",58.6,None, None],
102
- ["2024-Q3",58.8,None, None],
103
- ["2024-Q4",57.9,None, None],
104
- ],
105
- 'poblacion_ocupada': [
106
- ["2022-Q1", 510.8, 273.5, 237.3],
107
- ["2023-Q1", 479.3, 266.6, 212.8],
108
- ]
109
- },
110
- 'Ayacucho': {
111
- 'desempleo_trimestral': [
112
- ["2022-Q1", 8.6, None, None],
113
- ["2022-Q2", 5.5, None, None],
114
- ["2022-Q3", 3.6, None, None],
115
- ["2022-Q4", 5.1, None, None],
116
- ["2023-Q1", 9.3, 7.1, 11.8],
117
- ["2023-Q2", 7.4, 7.6, 7.2],
118
- ["2023-Q3", 7.0, 5.1, 9.1],
119
- ["2023-Q4", 4.7, 3.9, 5.6],
120
- ["2024-Q1", 6.5, 6.0, 7.0],
121
- ["2024-Q2", 9.0, 9.1, 8.9],
122
- ["2024-Q3", 5.4, 4.3, 6.7],
123
- ["2024-Q4", 5.7, 4.3, 7.3],
124
- ],
125
- 'ingresos_periodo': [
126
- ["2022-04/2023-03", 1565.1, 1778.2, 1297.6],
127
- ["2022-07/2023-06", 1591.9, 1816.0, 1315.6],
128
- ["2022-10/2023-09", 1605.3, 1850.7, 1306.1],
129
- ["2023-04/2024-03", 1670.0, 1932.4, 1351.8],
130
- ["2023-07/2024-06", 1715.0, 1977.5, 1399.3],
131
- ["2023-10/2024-09", 1750.7, 2008.7, 1439.4],
132
- ["2024", 1764.4, 2003.6, 1472.2]
133
- ],
134
- 'informal_periodo': [
135
- ["2023-04/2024-03", 59.6, 56.0, 64.0],
136
- ["2023-07/2024-06", 58.7, 55.3, 63.3],
137
- ["2023-10/2024-09", 59.5, 56.1, 64.0],
138
- ],
139
- 'actividad_trimestral': [
140
- ["2023-Q1", 68.3, None, None],
141
- ["2023-Q3", 72.0, None, None],
142
- ["2024-Q1", 70.3, None, None],
143
- ["2024-Q3", 70.9, None, None],
144
- ],
145
- 'poblacion_ocupada': [
146
- ["2022-Q1", 117.5, 64.3, 53.2],
147
- ["2022-Q2", 114.8, 63.3, 51.5],
148
- ["2022-Q3", 124.6, 68.3, 56.3],
149
- ["2023-Q1", 113.3, 62.9, 50.4],
150
- ["2023-Q2", 121.6, 63.5, 58.1],
151
- ["2023-Q3", 124.1, 66.9, 57.3],
152
- ["2023-Q4", 122.1, 65.8, 56.3],
153
- ["2024-Q1", 123.6, 67.4, 56.1],
154
- ["2024-Q2", 126.4, 66.9, 59.5],
155
- ["2024-Q3", 127.6, 69.0, 58.6],
156
- ["2024-Q4", 126.0, 68.8, 57.1],
157
- ]
158
- },
159
- 'Cajamarca': {
160
- 'desempleo_trimestral': [
161
- ["2022-Q1", 9.0, 7.2, 13.5],
162
- ["2022-Q2", 6.5, 6.5, 11.9],
163
- ["2022-Q3", 5.2, 7.2, 11.4],
164
- ["2022-Q4", 4.7, 4.9, 4.5],
165
- ["2023-Q1", 10.1, 7.2, 13.5],
166
- ["2023-Q2", 11.2, 10.6, 11.9],
167
- ["2023-Q3", 9.2, 7.2, 11.4],
168
- ["2023-Q4", 8.6, 7.4, 10.0],
169
- ["2024-Q1", 12.9, 11.8, 14.2],
170
- ["2024-Q2", 10.5, 10.1, 11.0],
171
- ["2024-Q3", 11.0, 10.7, 11.3],
172
- ["2024-Q4", 11.1, 10.8, 11.4],
173
- ],
174
- 'ingresos_periodo': [
175
- ["2022-04/2023-03", 1755.8, 2105.8, 1338.6],
176
- ["2022-07/2023-06", 1818.8, 2182.5, 1386.0],
177
- ["2022-10/2023-09", 1866.9, 2226.1, 1440.6],
178
- ["2023", 1922.4, 2294.7, 1475.5],
179
- ["2023-04/2024-03", 1958.2, 2343.5, 1490.0],
180
- ["2023-07/2024-06", 1936.7, 2295.6, 1503.6],
181
- ["2023-10/2024-09", 1942.5, 2318.6, 1493.6],
182
- ["2024", 1972.0, 2352.5, 1519.1],
183
- ],
184
- 'informal_periodo': [
185
- # No hay datos num茅ricos espec铆ficos, solo menciones gr谩ficas.
186
- ],
187
- 'actividad_trimestral': [
188
- ["2024-Q1", 65.5, None, None],
189
- ["2024-Q2", 65.9, None, None],
190
- ["2024-Q3", 67.2, None, None],
191
- ],
192
- 'poblacion_ocupada': [
193
- ["2022-Q1", 111.4, 61.4, 50.0],
194
- ["2022-Q2", 111.3, 60.8, 50.5],
195
- ["2022-Q3", 114.2, 61.1, 53.1],
196
- ["2023-Q1", 110.1, 60.2, 49.8],
197
- ["2023-Q2", 108.1, 57.0, 51.0],
198
- ["2023-Q3", 109.7, 58.7, 51.0],
199
- ["2024-Q1", 108.5, 60.2, 48.4],
200
- ["2024-Q2", 112.7, 60.3, 52.5],
201
- ["2024-Q3", 114.9, 60.0, 54.9],
202
- ]
203
- },
204
- 'Chachapoyas': {
205
- 'desempleo_trimestral': [
206
- ["2022-Q1", 7.2, 6.5, 10.8],
207
- ["2022-Q2", 2.9, 4.6, 6.1],
208
- ["2022-Q3", 2.6, 4.4, 7.3],
209
- ["2022-Q4", 3.3, 5.0, 4.4],
210
- ["2023-Q1", 8.5, 6.5, 10.8],
211
- ["2023-Q2", 5.3, 4.6, 6.1],
212
- ["2023-Q3", 5.8, 4.4, 7.3],
213
- ["2023-Q4", 4.7, 5.0, 4.4],
214
- ["2024-Q1", 7.8, 6.8, 8.9],
215
- ["2024-Q2", 7.0, 6.2, 7.9],
216
- ["2024-Q3", 5.6, 4.6, 6.7],
217
- ["2024-Q4", 4.6, 5.1, 4.1],
218
- ],
219
- 'ingresos_periodo': [
220
- ["2022-04/2023-03", 2100.8, 2414.0, 1738.8],
221
- ["2022-07/2023-06", 2125.8, 2456.4, 1744.5],
222
- ["2022-10/2023-09", 2180.9, 2518.0, 1784.0],
223
- ["2023", 2228.7, 2556.6, 1840.6],
224
- ["2023-04/2024-03", 2306.8, 2670.7, 1885.7],
225
- ["2023-07/2024-06", 2339.6, 2702.3, 1920.5],
226
- ["2023-10/2024-09", 2338.2, 2725.6, 1894.0],
227
- ["2024", 2323.5, 2744.6, 1847.9],
228
- ],
229
- 'informal_periodo': [
230
- # No hay datos num茅ricos espec铆ficos, solo inferencias de gr谩ficos.
231
- ],
232
- 'actividad_trimestral': [
233
- ["2023-Q1", 68.2, None, None],
234
- ["2023-Q3", 67.8, None, None],
235
- ["2024-Q1", 67.7, None, None],
236
- ["2024-Q2", 67.1, None, None],
237
- ["2024-Q3", 66.5, None, None],
238
- ],
239
- 'poblacion_ocupada': [
240
- ["2022-Q2", 19.6, 10.3, 9.2],
241
- ["2022-Q3", 20.5, 10.6, 9.8],
242
- ["2023-Q2", 19.4, 10.3, 9.1],
243
- ["2023-Q3", 19.3, 10.4, 8.9],
244
- ["2024-Q2", 19.2, 10.2, 9.0],
245
- ["2024-Q3", 19.5, 10.2, 9.2],
246
- ]
247
- },
248
- 'Chiclayo': {
249
- 'desempleo_trimestral': [
250
- ["2022-Q2", 5.0, None, 6.2],
251
- ["2022-Q3", 4.8, 7.0, 10.0],
252
- ["2022-Q4", 5.2, None, None],
253
- ["2023-Q1", 9.1, 7.1, 11.5],
254
- ["2023-Q2", 8.1, 6.2, 10.2],
255
- ["2023-Q3", 8.4, 7.0, 10.0],
256
- ["2023-Q4", 7.7, 6.7, 9.0],
257
- ["2024-Q1", 9.8, 7.7, 12.3],
258
- ["2024-Q2", 9.8, 9.7, 9.8],
259
- ["2024-Q3", 9.9, 8.5, 11.6],
260
- ["2024-Q4", 5.7, 5.1, 6.3],
261
- ],
262
- 'ingresos_periodo': [
263
- ["2023-04/2024-03", 1704.2, 1883.2, 1486.1],
264
- ["2023-07/2024-06", 1653.4, 1837.1, 1432.8],
265
- ["2023-10/2024-09", 1632.2, 1811.6, 1414.9],
266
- ["2024", 1636.7, 1832.9, 1400.3],
267
- ["2022-04/2023-03",1648.7,1905.1,1413.6],
268
- ["2022-10/2023-09",1718.2,1930.5,1457.5],
269
- ["2023",1714.7,1893.8,1493.9]
270
- ],
271
- 'informal_periodo': [
272
- # No hay datos num茅ricos espec铆ficos, solo inferencias de gr谩ficos.
273
- ],
274
- 'actividad_trimestral': [
275
- ["2023-Q1", 63.8, None, None],
276
- ["2023-Q3", 63.6, None, None],
277
- ["2024-Q1", 64.6, None, None],
278
- ["2024-Q3", 65.2, None, None],
279
- ],
280
- 'poblacion_ocupada': [
281
- ["2022-Q1", 298.4, 158.8, 139.6],
282
- ["2022-Q2", 272.0, 148.0, 124.0],
283
- ["2022-Q3", 298.4, 158.8, 139.6],
284
- ["2023-Q1", 274.5, 152.5, 122.0],
285
- ["2023-Q2", 272.0, 148.0, 124.0],
286
- ["2023-Q3", 276.7, 148.3, 128.4],
287
- ["2024-Q1", 277.3, 152.8, 124.5],
288
- ["2024-Q2", 276.6, 148.0, 128.5],
289
- ["2024-Q3", 280.4, 151.4, 129.0],
290
- ]
291
- },
292
- 'Chimbote': {
293
- 'desempleo_trimestral': [
294
- ["2023-Q1", 7.4, 5.8, 9.3],
295
- ["2023-Q2", 5.7, 4.3, 7.3],
296
- ["2023-Q3", 7.7, 6.5, 9.1],
297
- ["2023-Q4", 8.1, 7.6, 8.8],
298
- ["2024-Q1", 7.9, 6.7, 9.3],
299
- ["2024-Q2", 7.1, 6.0, 8.4],
300
- ["2024-Q3", 7.1, 5.6, 8.9],
301
- ["2024-Q4", 6.7, 6.1, 7.4],
302
- ],
303
- 'ingresos_periodo': [
304
- ["2022-04/2023-03", 1723.4, 2033.5, 1322.7],
305
- ["2023", 1795.0, 2126.4, 1375.1],
306
- ["2023-04/2024-03", 1856.7, 2226.1, 1391.3],
307
- ["2023-07/2024-06", 1863.5, 2198.6, 1432.0],
308
- ["2023-10/2024-09", 1897.0, 2251.0, 1438.0],
309
- ["2024", 1927.5, 2236.3, 1528.9],
310
- ["2022-07/2023-06",1737.3,2049.7,1343.4],
311
- ["2022-10/2023-09",1763.2,2079.7,1362.5]
312
- ],
313
- 'informal_periodo': [
314
- ["2023-07/2024-06", 68.7, 67.6, 70.2],
315
- ],
316
- 'actividad_trimestral': [
317
- ["2023-Q3", 63.5, None, None],
318
- ["2024-Q1", 66.5, None, None],
319
- ["2024-Q3", 61.9, None, None],
320
- ],
321
- 'poblacion_ocupada': [
322
- ["2023-Q1", 184.9, 104.0, 80.9],
323
- ["2023-Q2", 180.0, 101.6, 78.3],
324
- ["2023-Q3", 186.4, 105.6, 80.8],
325
- ["2024-Q1", 191.9, 106.9, 85.1],
326
- ["2024-Q2", 187.7, 105.2, 82.4],
327
- ["2024-Q3", 181.2, 102.7, 78.5],
328
- ]
329
- },
330
- 'Cusco': {
331
- 'desempleo_trimestral': [
332
- ["2022-Q1", 7.5, 7.5, 7.5],
333
- ["2022-Q2", 4.1, None, None],
334
- ["2022-Q3", 3.6, None, None],
335
- ["2022-Q4", 4.2, None, None],
336
- ["2023-Q1", 12.3, 11.5, 13.1],
337
- ["2023-Q2", 8.3, 8.3, 8.4],
338
- ["2023-Q3", 6.6, 4.7, 8.7],
339
- ["2023-Q4", 6.2, 4.8, 7.8],
340
- ["2024-Q1", 12.5, 10.3, 14.9],
341
- ["2024-Q2", 8.1, 8.4, 7.8],
342
- ["2024-Q3", 6.3, 4.3, 8.3],
343
- ["2024-Q4", 6.9, 6.6, 7.1],
344
- ],
345
- 'ingresos_periodo': [
346
- ["2022-04/2023-03", 1876.3, 2137.7, 1572.0],
347
- ["2023", 1960.0, 2159.4, 1724.4],
348
- ["2023-04/2024-03", 2003.4, 2226.7, 1745.8],
349
- ["2023-07/2024-06", 2009.0, 2240.7, 1748.2],
350
- ["2023-10/2024-09", 2041.7, 2275.8, 1778.8],
351
- ["2024", 2078.0, 2321.0, 1806.7],
352
- ###
353
- ["2022-07/2023-06", 1913.9, 2147.3, 1639.0],
354
- ["2022-10/2023-09", 1932.6, 2152.5, 1676.4],
355
- ],
356
- 'informal_periodo': [
357
- ["2023", 61.5, 54.0, 71.7], # Dato del a帽o 2023
358
- ["2022-04/2023-03",None,None,None],
359
- ["2022-07/2023-06",None,None,None],
360
- ["2022-10/2023-09",None,None,None],
361
- ["2023-04/2024-03",None,None,None],
362
- ["2023-07/2024-06",None,None,None],
363
- ["2023-10/2024-09",None,None,None],
364
- ["2024",None,None,None]
365
- ],
366
- 'actividad_trimestral': [
367
- ["2023-Q1", 62.4, None, None],
368
- ["2023-Q3", 68.2, None, None],
369
- ["2024-Q1", 69.3, None, None],
370
- ["2024-Q3", 68.7, None, None],
371
- ],
372
- 'poblacion_ocupada': [
373
- ["2022-Q1", 231.9, 123.8, 108.1],
374
- ["2022-Q2", 239.3, 125.1, 114.2],
375
- ["2022-Q3", 238.5, 127.3, 111.2],
376
- ["2023-Q1", 205.0, 111.4, 93.6],
377
- ["2023-Q2", 229.1, 123.6, 105.4],
378
- ["2023-Q3", 240.1, 128.4, 111.8],
379
- ["2024-Q1", 230.3, 121.9, 108.4],
380
- ["2024-Q2", 239.3, 123.9, 115.4],
381
- ["2024-Q3", 246.0, 129.2, 116.8],
382
- ]
383
- },
384
- 'Huancavelica': {
385
- 'desempleo_trimestral': [
386
- ["2022-Q1", 10.5, 13.5, 17.1],
387
- ["2022-Q2", 5.8, None, None],
388
- ["2022-Q3", 4.6, None, None],
389
- ["2022-Q4", 5.4, 5.2, 5.7],
390
- ["2023-Q1", 15.2, 13.5, 17.1],
391
- ["2023-Q2", 10.7, 12.3, 8.9],
392
- ["2023-Q3", 8.2, 8.9, 7.5],
393
- ["2023-Q4", 9.1, 8.9, 9.2],
394
- ["2024-Q1", 14.5, 15.1, 13.8],
395
- ["2024-Q2", 13.4, 13.1, 13.6],
396
- ["2024-Q3", 11.5, 12.1, 10.8],
397
- ["2024-Q4", 8.7, 9.3, 8.0],
398
- ],
399
- 'ingresos_periodo': [
400
- ["2022-04/2023-03", 1638.8, 1819.8, 1420.1],
401
- ["2022-07/2023-06", 1676.8, 1876.2, 1440.6],
402
- ["2022-10/2023-09", 1660.6, 1856.6, 1432.5],
403
- ["2023", 1732.1, 1954.8, 1478.8],
404
- ["2023-04/2024-03", 1776.9, 2011.0, 1509.6],
405
- ["2023-07/2024-06", 1815.6, 2050.0, 1543.0],
406
- ["2023-10/2024-09", 1861.6, 2096.7, 1590.1],
407
- ["2024", 1864.4, 2096.0, 1595.9],
408
- ],
409
- 'informal_periodo': [
410
- ["2023", 61.0, 59.5, 62.6],
411
- ],
412
- 'actividad_trimestral': [
413
- ["2022-Q3",68.9,None,None],
414
- ["2023-Q2",66.9,None,None],
415
- ["2023-Q3",68.9,None,None],
416
- ["2024-Q1",66.3,None,None],
417
- ["2024-Q2",68.7,None,None],
418
- ["2024-Q3",71.3,None,None]
419
- ],
420
- 'poblacion_ocupada': [
421
- ["2022-Q1", 26.1, 14.4, 11.7],
422
- ["2022-Q2", 40.7, 23.2, 17.5],
423
- ["2022-Q3", 27.4, 14.5, 12.8],
424
- ["2023-Q1", 23.4, 12.8, 10.7],
425
- ["2023-Q2", 26.3, 13.4, 12.9],
426
- ["2023-Q3", 28.0, 14.7, 13.3],
427
- ["2024-Q1", 26.8, 14.1, 12.6],
428
- ["2024-Q2", 26.8, 14.1, 12.6],
429
- ["2024-Q3", 28.5, 14.9, 13.6],
430
- ]
431
- },
432
- 'Huancayo': {
433
- 'desempleo_trimestral': [
434
- ["2022-Q1", 7.4, 7.7, 13.5],
435
- ["2022-Q2", 3.9, 7.5, 8.4],
436
- ["2022-Q3", 3.5, 5.2, 6.6],
437
- ["2022-Q4", 4.1, None, None],
438
- ["2023-Q1", 10.5, 10.3, 10.1],
439
- ["2023-Q2", 7.9, 7.5, 8.4],
440
- ["2023-Q3", 5.9, 5.2, 6.6],
441
- ["2023-Q4", 7.4, 6.5, 8.4],
442
- ["2024-Q1", 10.2, 10.3, 10.1],
443
- ["2024-Q2", 8.4, 7.2, 9.6],
444
- ["2024-Q3", 7.2, 9.0, 5.4],
445
- ["2024-Q4", 6.7, 5.5, 8.1],
446
- ],
447
- 'ingresos_periodo': [
448
- ["2022-04/2023-03", 1665.5, 1927.0, 1367.5],
449
- ["2022-07/2023-06", 1702.3, 1978.8, 1387.9],
450
- ["2022-10/2023-09", 1705.7, 1992.6, 1382.4],
451
- ["2023", 1715.8, 2007.6, 1388.0],
452
- ["2023-04/2024-03", 1707.7, 2003.1, 1383.4],
453
- ["2023-07/2024-06", 1705.3, 2014.3, 1364.7],
454
- ["2023-10/2024-09", 1724.5, 2029.0, 1395.4],
455
- ["2024", 1754.2, 2061.6, 1410.3],
456
- ],
457
- 'informal_periodo': [
458
- ["2023", 66.6, 63.9, 69.6],
459
- ],
460
- 'actividad_trimestral': [
461
- ["2022-Q3", 67.0, None, None],
462
- ["2023-Q1", 66.4, None, None],
463
- ["2023-Q3", 67.0, None, None],
464
- ["2024-Q1", 65.4, None, None],
465
- ["2024-Q3", 62.9, None, None],
466
- ],
467
- 'poblacion_ocupada': [
468
- ["2022-Q1", 253.5, 128.0, 125.5],
469
- ["2022-Q2", 255.8, 130.2, 125.6],
470
- ["2022-Q3", 266.1, 142.2, 123.9],
471
- ["2023-Q1", 251.9, 134.2, 117.6],
472
- ["2023-Q2", 252.1, 129.4, 122.7],
473
- ["2023-Q3", 268.9, 142.4, 126.5],
474
- ["2023-Q4", 259.4, None, None],
475
- ["2024-Q1", 252.2, 130.1, 122.1],
476
- ["2024-Q2", 254.7, 130.2, 124.4],
477
- ["2024-Q3", 252.4, 129.0, 123.5],
478
- ["2024-Q4", 257.3, 139.5, 117.8]
479
- ]
480
- },
481
- 'Hu谩nuco': {
482
- 'desempleo_trimestral': [
483
- ["2022-Q1", 10.2, 8.3, 12.2],
484
- ["2022-Q2", 3.9, 6.5, 10.7],
485
- ["2022-Q3", 3.8, 4.4, 7.5],
486
- ["2022-Q4", 4.2, None, None],
487
- ["2023-Q1", 10.0, 8.3, 12.2],
488
- ["2023-Q2", 8.5, 6.5, 10.7],
489
- ["2023-Q3", 5.8, 4.4, 7.5],
490
- ["2023-Q4", 6.8, 6.9, 6.6],
491
- ["2024-Q1", 10.1, 8.4, 12.5],
492
- ["2024-Q2", 7.0, 7.1, 7.0],
493
- ["2024-Q3", 8.7, 7.2, 10.4],
494
- ["2024-Q4", 4.1, 1.7, 7.2],
495
- ],
496
- 'ingresos_periodo': [
497
- ["2022-04/2023-03", 1733.4, 1966.6, 1415.4],
498
- ["2022-07/2023-06", 1796.7, 2027.4, 1492.1],
499
- ["2022-10/2023-09", 1864.3, 2065.9, 1592.7],
500
- ["2023", 1919.4, 2115.1, 1657.2],
501
- ["2023-04/2024-03", 1931.0, 2119.8, 1677.8],
502
- ["2023-07/2024-06", 1958.5, 2132.6, 1722.6],
503
- ["2023-10/2024-09", 1963.3, 2122.9, 1747.3],
504
- ["2024", 1957.5, 2095.7, 1766.8],
505
- ],
506
- 'informal_periodo': [
507
- # No hay datos num茅ricos espec铆ficos, solo inferencias de gr谩ficos.
508
- ],
509
- 'actividad_trimestral': [
510
- ["2023-Q3", 66.3, None, None],
511
- ["2024-Q1", 65.3, None, None],
512
- ["2024-Q3", 62.3, None, None],
513
- ],
514
- 'poblacion_ocupada': [
515
- ["2024-Q2", 64.0, 35.0, 29.0],
516
- ["2024-Q3", 64.0, 35.6, 28.3],
517
- ]
518
- },
519
- 'Huaraz': {
520
- 'desempleo_trimestral': [
521
- ["2022-Q1", 5.6, 4.1, 6.8],
522
- ["2022-Q2", 3.7, 4.9, 7.3],
523
- ["2022-Q3", 2.1, 3.5, 6.7],
524
- ["2022-Q4", 2.4, 2.8, 2.3],
525
- ["2023-Q1", 5.2, 4.1, 6.8],
526
- ["2023-Q2", 6.0, 4.9, 7.3],
527
- ["2023-Q3", 4.9, 3.5, 6.7],
528
- ["2023-Q4", 4.7, 5.0, 4.3],
529
- ["2024-Q1", 7.1, 5.5, 9.2],
530
- ["2024-Q2", 7.1, 8.0, 6.0],
531
- ["2024-Q3", 6.7, 8.0, 4.9],
532
- ["2024-Q4", 7.0, 7.7, 6.1],
533
- ],
534
- 'ingresos_periodo': [
535
- ["2022-04/2023-03", 1768.5, 2091.1, 1335.7],
536
- ["2022-07/2023-06", 1802.9, 2105.0, 1404.7],
537
- ["2022-10/2023-09", 1826.5, 2092.7, 1463.3],
538
- ["2023", 1862.5, 2121.2, 1497.5],
539
- ["2023-04/2024-03", 1870.7, 2119.2, 1520.4],
540
- ["2023-07/2024-06", 1909.0, 2153.3, 1565.4],
541
- ["2023-10/2024-09", 1902.1, 2114.9, 1607.4],
542
- ["2024", 1936.9, 2149.9, 1652.0],
543
- ],
544
- 'informal_periodo': [
545
- # No hay datos num茅ricos espec铆ficos, solo inferencias de gr谩ficos.
546
- ],
547
- 'actividad_trimestral': [
548
- ["2023-Q1", 63.3, None, None],
549
- ["2023-Q3", 62.8, 71.6, 54.0],
550
- ["2024-Q1", 62.9, None, None],
551
- ["2024-Q3", 61.6, 70.0, 53.3],
552
- ],
553
- 'poblacion_ocupada': [
554
- ["2022-Q2", 62.5, 36.1, 26.4],
555
- ["2022-Q3", 68.6, 38.1, 30.5],
556
- ["2023-Q1", 65.1, 37.5, 27.5],
557
- ["2023-Q2", 65.3, 35.8, 29.5],
558
- ["2023-Q3", 65.3, 37.6, 27.8],
559
- ["2024-Q1", 64.5, 37.3, 27.3],
560
- ["2024-Q2", 64.0, 35.0, 29.0],
561
- ["2024-Q3", 64.0, 35.6, 28.3],
562
- ]
563
- },
564
- 'Ica': {
565
- 'desempleo_trimestral': [
566
- ["2022-Q3", 3.1, None, None],
567
- ["2022-Q4", 5.3, 4.3, 6.6],
568
- ["2023-Q3", 7.6, 6.4, 9.0],
569
- ["2023-Q4", 5.3, 4.3, 6.6],
570
- ["2024-Q3", 7.1, 5.8, 8.9],
571
- ["2024-Q4", 8.2, 6.8, 10.0],
572
- ],
573
- 'ingresos_periodo': [
574
- ["2022-10/2023-09", 1969.4, 2172.6, 1696.0],
575
- ["2023-10/2024-09", 2055.1, 2276.2, 1750.1],
576
- ["2024", 2032.6, 2237.5, 1747.5],
577
- ],
578
- 'informal_periodo': [
579
- # No hay datos num茅ricos espec铆ficos, solo inferencias de gr谩ficos.
580
- ],
581
- 'actividad_trimestral': [],
582
- 'poblacion_ocupada': [
583
- ["2022-Q3", 175.4, 99.7, 75.8],
584
- ["2023-Q1", 168.2, 98.6, 69.5],
585
- ["2023-Q2", 169.0, 95.4, 73.6],
586
- ["2023-Q3", 172.0, 96.1, 75.8],
587
- ["2024-Q1", 162.8, 94.2, 68.6],
588
- ["2024-Q2", 166.7, 97.2, 69.5],
589
- ["2024-Q3", 172.1, 99.5, 72.6],
590
- ]
591
- },
592
- 'Iquitos': {
593
- 'desempleo_trimestral': [
594
- ["2022-Q3", 3.2, None, None],
595
- ["2022-Q4", 3.4, None, None],
596
- ["2023-Q1", 8.1, 7.4, 9.0],
597
- ["2023-Q2", 7.0, 6.2, 7.9],
598
- ["2023-Q3", 6.2, 6.6, 5.7],
599
- ["2023-Q4", 6.3, 5.3, 7.7],
600
- ["2024-Q1", 8.1, 7.4, 9.1],
601
- ["2024-Q2", 7.6, 6.1, 9.6],
602
- ["2024-Q3", 8.0, 8.1, 8.0],
603
- ["2024-Q4", 4.2, 3.7, 4.8],
604
- ],
605
- 'ingresos_periodo': [
606
- ["2022-04/2023-03", 1581.5, 1723.7, 1396.7],
607
- ["2022-07/2023-06", 1623.0, 1786.5, 1413.3],
608
- ["2022-10/2023-09", 1671.5, 1837.8, 1458.2],
609
- ["2023", 1702.8, 1884.1, 1467.3],
610
- ["2023-04/2024-03", 1728.4, 1919.9, 1476.4],
611
- ["2023-07/2024-06", 1716.9, 1891.9, 1480.4],
612
- ["2023-10/2024-09", 1725.3, 1894.0, 1494.4],
613
- ["2024", 1741.9, 1898.3, 1532.0],
614
- ],
615
- 'informal_periodo': [
616
- ["2022-07/2023-06", 73.8, None, None],
617
- ["2022-10/2023-09", 74.1, None, None],
618
- ["2023", 73.1, 71.6, 75.9],
619
- ["2023-04/2024-03", 73.8, None, None],
620
- ["2023-07/2024-06", 72.8, None, None],
621
- ["2023-10/2024-09", 72.8, None, None],
622
- ["2024", 72.4, None, None],
623
- ],
624
- 'actividad_trimestral': [
625
- ["2022", 72.5, None, None],
626
- ["2023-Q3", 69.4, None, None],
627
- ["2023", 70.3, None, None],
628
- ["2024-Q3", 71.8, None, None],
629
- ],
630
- 'poblacion_ocupada': [
631
- ["2022-Q1", 218.6, 119.4, 99.2],
632
- ["2022-Q2", 221.6, 124.1, 97.4],
633
- ["2022-Q3", 232.4, 127.8, 104.5],
634
- ["2023-Q1", 212.0, 119.7, 92.3],
635
- ["2023-Q2", 215.7, 117.4, 98.3],
636
- ["2023-Q3", 213.8, 119.2, 94.5],
637
- ["2024-Q3", 218.5, 123.4, 95.1],
638
- ]
639
- },
640
- 'Lima Metropolitana y la Provincia Constitucional del Callao': {
641
- 'desempleo_trimestral': [
642
- ["2022-Q1", 9.4, 6.4, 8.7],
643
- ["2022-Q2", 6.8, None, None],
644
- ["2022-Q3", 7.7, None, None],
645
- ["2022-Q4", 7.1, None, None],
646
- ["2023-Q1", 7.5, 6.4, 8.7],
647
- ["2023-Q2", 6.6, 6.0, 7.1],
648
- ["2023-Q3", 6.7, 5.8, 7.8],
649
- ["2023-Q4", 6.4, 5.2, 7.8],
650
- ["2024-Q1", 7.7, 6.8, 8.7],
651
- ["2024-Q2", 6.6, 6.0, 7.3],
652
- ["2024-Q3", 5.9, 5.0, 7.1],
653
- ["2024-Q4", 5.5, 5.0, 6.1],
654
- ],
655
- 'ingresos_periodo': [
656
- ["2022-04/2023-03", 1949.9, 2213.6, 1627.9],
657
- ["2022-07/2023-06", 2032.3, 2294.5, 1715.2],
658
- ["2023", 2141.1, 2430.3, 1797.4],
659
- ["2023-04/2024-03", 2176.2, 2472.3, 1823.8],
660
- ["2023-07/2024-06", 2189.5, 2506.0, 1816.4],
661
- ["2023-10/2024-09", 2217.8, 2519.7, 1859.8],
662
- ["2024", 2268.9, 2565.8, 1915.4],
663
- ],
664
- 'informal_periodo': [
665
- ["2022-07/2023-06", 58.0, 55.3, 61.2],
666
- ["2023", 56.7, 53.9, 59.9],
667
- ["2023-04/2024-03", 57.3, 54.5, 60.6],
668
- ["2023-07/2024-06", 57.3, 54.6, 60.4],
669
- ["2023-10/2024-09", 57.3, 54.9, 60.1],
670
- ["2024", 57.0, 54.2, 60.2],
671
- ],
672
- 'actividad_trimestral': [
673
- ["2023-Q3", 65.4, None, None],
674
- ["2024-Q1", 66.7, None, None],
675
- ["2024-Q2", 66.5, None, None],
676
- ["2024-Q3", 65.4, None, None],
677
- ],
678
- 'poblacion_ocupada': [
679
- ["2022-Q1", 4921.1, 2732.9, 2188.3],
680
- ["2022-Q2", 5087.7, 2771.6, 2316.0],
681
- ["2022-Q3", 4982.9, 2734.5, 2248.4],
682
- ["2022-Q4", 5019.4, 2754.0, 2265.5],
683
- ["2023-Q1", 5124.4, 2749.1, 2375.3],
684
- ["2023-Q2", 5215.5, 2800.2, 2415.4],
685
- ["2023-Q3", 5208.3, 2823.0, 2385.2],
686
- ["2023-Q4", 5217.0, 2807.6, 2409.4],
687
- ["2024-Q1", 5359.7, 2892.8, 2466.9],
688
- ["2024-Q2", 5461.3, 2891.5, 2569.7],
689
- ["2024-Q3", 5461.7, 2985.0, 2476.8],
690
- ["2024-Q4", 5459.2, 2942.9, 2516.4],
691
- ]
692
- },
693
- 'Moquegua': {
694
- 'desempleo_trimestral': [
695
- ["2022-Q1", 10.5, 9.7, 11.6],
696
- ["2022-Q2", 6.0, None, None],
697
- ["2022-Q3", 6.6, None, None],
698
- ["2022-Q4", 9.2, None, None],
699
- ["2023-Q1", 14.8, 12.9, 17.3],
700
- ["2023-Q2", 10.0, 9.2, 11.2],
701
- ###
702
- ["2023-Q3", 11.4, 10.8, 12.2],
703
- ["2023-Q4", 11.1, 9.7, 13.0],
704
- ["2024-Q1", 14.4, 11.3, 18.6],
705
- ["2024-Q2", 11.1, 8.6, 14.4],
706
- ["2024-Q3", 11.2, 8.1, 15.0],
707
- ["2024-Q4", 6.3, 6.8, 5.5],
708
- ],
709
- 'ingresos_periodo': [
710
- ["2022-04/2023-03", 2002.0, 2313.2, 1570.7],
711
- ["2022-07/2023-06", 2075.2, 2402.3, 1609.8],
712
- ["2022-10/2023-09", 2141.5, 2492.6, 1642.4],
713
- ["2023", 2174.3, 2517.8, 1673.8],
714
- ["2023-04/2024-03", 2195.7, 2516.1, 1729.2],
715
- ["2023-07/2024-06", 2206.9, 2517.5, 1756.6],
716
- ["2023-10/2024-09", 2222.2, 2540.8, 1766.5],
717
- ],
718
- 'informal_periodo': [
719
- ["2023", 54.1, 50.9, 58.5],
720
- ["2024",54.1,50.9,58.5]
721
- ],
722
- 'actividad_trimestral': [
723
- ["2023-Q1",64.2,None,None],
724
- ["2023-Q3",66.0,None,None],
725
- ["2024-Q1",69.1,None,None]
726
- ],
727
- 'poblacion_ocupada': [
728
- ["2022-Q2", 40.7, 23.2, 17.5],
729
- ["2022-Q3", 40.0, 23.4, 16.7],
730
- ["2023-Q1", 36.6, 21.4, 15.1],
731
- ["2023-Q2", 40.9, 24.2, 16.7],
732
- ["2023-Q3", 39.6, 23.2, 16.4],
733
- ["2024-Q1", 40.5, 23.7, 16.8],
734
- ["2024-Q2", 42.7, 25.2, 17.5],
735
- ["2024-Q3", 42.9, 24.6, 18.3],
736
- ]
737
- },
738
- 'Moyobamba': {
739
- 'desempleo_trimestral': [
740
- ["2022-Q1", 3.7, 5.9, 6.1],
741
- ["2022-Q2", 1.8, 3.4, 2.7],
742
- ["2022-Q3", 1.1, 3.4, 4.4],
743
- ["2022-Q4", 1.9, 3.8, 6.1],
744
- ["2023-Q1", 6.0, 5.9, 6.1],
745
- ["2023-Q2", 3.2, 3.4, 2.7],
746
- ["2023-Q3", 3.8, 3.4, 4.4],
747
- ["2023-Q4", 4.3, 3.3, 5.8],
748
- ["2024-Q1", 6.8, 5.1, 9.2],
749
- ["2024-Q2", 3.4, 3.1, 3.8],
750
- ["2024-Q3", 4.0, 3.0, 5.3],
751
- ["2024-Q4", 3.0, 3.0, 3.1],
752
- ],
753
- 'ingresos_periodo': [
754
- ["2022-07/2023-06", 1778.8, 1927.2, 1554.4],
755
- ["2022-10/2023-09", 1753.7, 1893.1, 1537.0],
756
- ["2023", 1738.2, 1858.6, 1547.1],
757
- ["2023-04/2024-03", 1743.8, 1868.6, 1546.7],
758
- ["2023-07/2024-06", 1726.2, 1841.2, 1548.6],
759
- ["2023-10/2024-09", 1734.6, 1860.1, 1543.5],
760
- ["2024", 1730.3, 1882.3, 1504.7],
761
- ["2022-04/2023-03",1753.1,1905.7,1523.4]
762
- ],
763
- 'informal_periodo': [
764
- ["2023-10/2024-09",None,72.9,74.3],
765
- ["2024",None,70.3,68.5],
766
- ["2023-04/2024-03",69.0,69.2,68.6]
767
- ],
768
- 'actividad_trimestral': [
769
- ["2022-Q3", 72.6, None, None],
770
- ["2023-Q3", 72.6, None, None],
771
- ["2024-Q1", 73.7, None, None],
772
- ["2024-Q2", 73.5, None, None],
773
- ["2024-Q3", 73.1, None, None],
774
- ],
775
- 'poblacion_ocupada': [
776
- ["2022-Q1", 32.0, 19.0, 13.0],
777
- ["2022-Q2", 33.2, 19.6, 13.6],
778
- ["2022-Q3", 34.0, 19.9, 14.1],
779
- ["2023-Q1", 32.4, 19.0, 13.4],
780
- ["2023-Q2", 32.6, 19.4, 13.2],
781
- ["2023-Q3", 32.6, 19.6, 13.1],
782
- ["2024-Q1", 33.8, None, None],
783
- ["2024-Q2", 33.8, 19.3, 14.5],
784
- ["2024-Q3", 33.6, 19.6, 14.0],
785
- ]
786
- },
787
- 'Cerro de Pasco': {
788
- 'desempleo_trimestral': [
789
- ["2022-Q1", 7.5, 5.8, 9.3],
790
- ["2022-Q2", 5.2, None, None],
791
- ["2022-Q3", 3.3, 5.3, 6.6],
792
- ["2022-Q4", 5.7, 3.2, 5.5],
793
- ["2023-Q1", 9.5, 7.9, 11.5],
794
- ["2023-Q2", 6.7, 6.7, 8.8],
795
- ["2023-Q3", 5.9, 5.3, 6.6],
796
- ["2023-Q4", 4.2, 3.2, 5.5],
797
- ["2024-Q1", 10.1, 9.1, 11.5],
798
- ["2024-Q2", 7.6, 6.8, 8.6],
799
- ["2024-Q3", 7.7, 7.6, 7.7],
800
- ["2024-Q4", 6.4, 5.1, 8.1],
801
- ],
802
- 'ingresos_periodo': [
803
- ["2022-04/2023-03", 1679.1, 2036.5, 1216.6],
804
- ["2022-07/2023-06", 1738.4, 2113.4, 1238.4],
805
- ["2022-10/2023-09", 1779.2, 2170.1, 1238.5],
806
- ["2023", 1783.2, 2162.7, 1245.5],
807
- ["2023-04/2024-03", 1811.3, 2190.5, 1271.8],
808
- ["2023-07/2024-06", 1808.9, 2210.8, 1252.4],
809
- ["2023-10/2024-09", 1844.0, 2269.1, 1270.0],
810
- ["2024", 1870.4, 2313.9, 1267.6],
811
- ],
812
- 'informal_periodo': [
813
- # No hay datos num茅ricos espec铆ficos, solo inferencias de gr谩ficos.
814
- ],
815
- 'actividad_trimestral': [
816
- ["2023-Q3",64.8,None,None],
817
- ["2024-Q3",63.8,None,None]
818
- ],
819
- 'poblacion_ocupada': [
820
- ["2022-Q2", 28.9, 15.8, 13.1],
821
- ["2022-Q3", 29.5, 16.3, 13.2],
822
- ["2023-Q1", 27.5, 15.5, 12.0],
823
- ["2023-Q2", 29.4, 16.9, 12.5],
824
- ["2023-Q3", 28.4, 16.4, 12.0],
825
- ["2023-Q4", 28.4, 16.3, 12.1],
826
- ["2024-Q1", 24.2, 14.0, 10.2],
827
- ["2024-Q2", 27.2, 15.0, 12.2],
828
- ["2024-Q3", 27.3, 15.7, 11.6],
829
- ["2024-Q4", 26.6, 15.1, 11.4]
830
- ]
831
- },
832
- 'Piura': {
833
- 'desempleo_trimestral': [
834
- ["2022-Q1", 5.4, None, None],
835
- ["2022-Q2", 3.2, None, None],
836
- ["2022-Q3", 2.9, None, None],
837
- ["2022-Q4", 3.4, None, None],
838
- ["2023-Q1", 9.2, 8.3, 10.1],
839
- ["2023-Q2", 6.7, 5.0, 8.7],
840
- ["2023-Q3", 6.0, 6.4, 5.5],
841
- ["2023-Q4", 6.6, 5.6, 7.7],
842
- ["2024-Q1", 9.5, 7.9, 11.2],
843
- ["2024-Q2", 8.2, 7.2, 9.4],
844
- ["2024-Q3", 6.9, 4.6, 9.5],
845
- ["2024-Q4", 8.0, 5.7, 10.7],
846
- ],
847
- 'ingresos_periodo': [
848
- ["2022-04/2023-03", 1799.1, 2055.2, 1490.1],
849
- ["2022-07/2023-06", 1805.6, 2064.7, 1494.2],
850
- ["2022-10/2023-09", 1842.5, 2101.1, 1533.2],
851
- ["2023", 1839.3, 2103.5, 1520.5],
852
- ["2023-04/2024-03", 1839.8, 2099.2, 1527.5],
853
- ["2023-07/2024-06", 1856.8, 2104.4, 1555.9],
854
- ["2023-10/2024-09", 1856.8, 2105.2, 1547.8],
855
- ["2024", 1856.5, 2084.4, 1569.8],
856
- ],
857
- 'informal_periodo': [
858
- # No hay datos num茅ricos espec铆ficos, solo inferencias de gr谩ficos.
859
- ],
860
- 'actividad_trimestral': [
861
- ["2023-Q3", 70.1, None, None],
862
- ["2024-Q3", 69.0, None, None],
863
- ],
864
- 'poblacion_ocupada': [
865
- ["2022-Q3", 293.0, 159.1, 133.9],
866
- ]
867
- },
868
- 'Pucallpa': {
869
- 'desempleo_trimestral': [
870
- ["2022-Q1", 4.2, None, None],
871
- ["2022-Q3", 2.0, None, None],
872
- ["2022-Q4", 1.9, None, None],
873
- ["2023-Q1", 4.7, 4.2, 5.4],
874
- ["2023-Q2", 2.9, 2.5, 3.6],
875
- ["2023-Q3", 5.7, 4.6, 7.3],
876
- ["2023-Q4", 4.8, 3.8, 6.1],
877
- ["2024-Q1", 6.6, 6.4, 6.8],
878
- ["2024-Q2", 7.4, 7.3, 7.5],
879
- ["2024-Q3", 4.9, 5.0, 4.8],
880
- ["2024-Q4", 4.6, 3.4, 6.1],
881
- ],
882
- 'ingresos_periodo': [
883
- ["2022-04/2023-03", 1583.0, 1698.1, 1412.8],
884
- ["2022-07/2023-06", 1587.9, 1712.9, 1402.5],
885
- ["2022-10/2023-09", 1591.5, 1714.7, 1404.1],
886
- ["2023", 1616.2, 1736.1, 1430.3],
887
- ["2023-04/2024-03", 1626.1, 1741.0, 1450.3],
888
- ["2023-07/2024-06", 1623.8, 1729.1, 1463.0],
889
- ["2023-10/2024-09", 1627.5, 1720.2, 1488.0],
890
- ["2024", 1628.0, 1711.5, 1501.3],
891
- ],
892
- 'informal_periodo': [
893
- ["2023-04/2024-03", 74.2, 72.9, 75.9],
894
- ],
895
- 'actividad_trimestral': [
896
- ["2023-Q1",68.3,None,None],
897
- ["2023-Q2",67.7,None,None],
898
- ["2023-Q3",66.2,None,None],
899
- ["2024-Q1",67.9,None,None],
900
- ["2024-Q2",66.1,None,None],
901
- ["2024-Q3",68.7,None,None]
902
- ],
903
- 'poblacion_ocupada': [
904
- ["2022-Q1", 189.1, 115.1, 74.0],
905
- ["2022-Q3", 232.4, 127.8, 104.5],
906
- ["2023-Q1", 190.0, 112.6, 77.4],
907
- ["2024-Q1",190.0,112.6,77.4]
908
- ]
909
- },
910
- 'Puerto Maldonado': {
911
- 'desempleo_trimestral': [
912
- ["2022-Q4", 2.0, None, None],
913
- ["2023-Q1", 6.1, 4.9, 8.3],
914
- ["2023-Q2", 4.5, 3.9, 5.6],
915
- ["2023-Q3", 4.3, 2.9, 6.4],
916
- ["2023-Q4", 5.2, 4.3, 6.7],
917
- ["2024-Q1", 6.4, 3.9, 10.5],
918
- ["2024-Q2", 7.8, 6.0, 10.7],
919
- ["2024-Q3", 6.7, 5.2, 9.1],
920
- ["2024-Q4", 5.6, 4.3, 7.8],
921
- ],
922
- 'ingresos_periodo': [
923
- ["2022-04/2023-03", 1911.6, 2075.4, 1622.0],
924
- ["2022-07/2023-06", 1893.7, 2034.2, 1641.7],
925
- ["2022-10/2023-09", 1871.5, 2002.7, 1637.3],
926
- ["2023", 1869.8, 1995.4, 1645.5],
927
- ["2023-04/2024-03", 1872.8, 1992.9, 1654.6],
928
- ["2023-07/2024-06", 1904.0, 2037.4, 1662.8],
929
- ["2023-10/2024-09", 1955.6, 2095.1, 1700.2],
930
- ["2024", 1973.6, 2113.7, 1715.4],
931
- ],
932
- 'informal_periodo': [
933
- ["2022-04/2023-03",None,None,None],
934
- ["2022-07/2023-06",None,None,None],
935
- ["2022-10/2023-09",None,None,None],
936
- ["2023", 70.5, 72.0, 68.0],
937
- ["2023-04/2024-03", 70.7, 71.8, 68.9],
938
- ["2023-07/2024-06", 70.7, 71.8, 68.9],
939
- ["2023-10/2024-09", 70.3, 70.9, 69.1],
940
- ["2024", 73.5,72.5,73.5],
941
- ],
942
- 'actividad_trimestral': [
943
- ["2023-Q1",68.3,None,None],
944
- ["2023-Q2",74.8,None,None],
945
- ["2023-Q3",75.8,None,None],
946
- ["2024-Q1",72.4,None,None],
947
- ["2024-Q2",74.8,None,None],
948
- ["2024-Q3",72.2,None,None]
949
- ],
950
- 'poblacion_ocupada': [
951
- ["2022-Q2", 60.4, 38.6, 21.8],
952
- ["2022-Q3", 66.8, 42.3, 24.4],
953
- ["2023-Q1", 59.2, 37.5, 21.7],
954
- ["2023-Q2", 66.6, 41.7, 24.9],
955
- ["2023-Q3", 68.4, 42.5, 25.8],
956
- ["2024-Q2",66.8,42.0,24.7],
957
- ["2024-Q3",65.9,42.0,23.9]
958
- ]
959
- },
960
- 'Puno': {
961
- 'desempleo_trimestral': [
962
- ["2023-Q1", 15.3, 13.4, 17.7],
963
- ["2023-Q2", 9.3, 10.3, 8.2],
964
- ["2023-Q3", 8.5, 8.8, 8.1],
965
- ["2023-Q4", 6.2, 6.1, 6.3],
966
- ["2024-Q1", 11.9, 10.9, 13.0],
967
- ["2024-Q2", 7.7, 7.2, 8.3],
968
- ["2024-Q3", 8.4, 7.1, 9.9],
969
- ["2024-Q4", 5.2, 5.7, 4.6],
970
- ],
971
- 'ingresos_periodo': [
972
- ["2022-04/2023-03", 1672.8, 1950.7, 1361.2],
973
- ["2022-07/2023-06", 1672.8, 1950.7, 1361.2],
974
- ["2022-10/2023-09", 1700.3, 1958.8, 1416.7],
975
- ["2023", 1731.9, 1977.9, 1462.7],
976
- ["2023-04/2024-03", 1763.4, 1995.6, 1508.9],
977
- ["2023-07/2024-06", 1809.9, 2038.3, 1556.1],
978
- ["2023-10/2024-09", 1789.5, 1996.4, 1552.3],
979
- ["2024", 1804.6, 2006.0, 1568.1],
980
- ],
981
- 'informal_periodo': [
982
- # No hay datos num茅ricos espec铆ficos, solo inferencias de gr谩ficos.
983
- ],
984
- 'actividad_trimestral': [],
985
- 'poblacion_ocupada': []
986
- },
987
- 'Tacna': {
988
- 'desempleo_trimestral': [
989
- ["2022-Q1", 7.1, None, None],
990
- ["2022-Q2", 3.5, None, None],
991
- ["2022-Q3", 2.7, None, None],
992
- ["2022-Q4", 2.8, None, None],
993
- ["2023-Q1", 8.8, 8.7, 8.9],
994
- ["2023-Q2", 7.4, 6.6, 8.4],
995
- ["2023-Q3", 5.9, 6.1, 5.7],
996
- ["2023-Q4", 5.1, 4.5, 6.0],
997
- ["2024-Q1", 8.5, 7.6, 9.7],
998
- ["2024-Q2", 8.3, 9.0, 7.5],
999
- ["2024-Q3", 6.6, 5.8, 7.6],
1000
- ["2024-Q4", 6.1, 6.2, 6.0],
1001
- ],
1002
- 'ingresos_periodo': [
1003
- ["2022-04/2023-03", 1536.4, 1708.2, 1313.5],
1004
- ["2022-07/2023-06", 1568.6, 1737.1, 1349.7],
1005
- ["2022-10/2023-09", 1603.6, 1766.7, 1394.7],
1006
- ["2023", 1624.3, 1785.2, 1420.0],
1007
- ["2023-04/2024-03", 1659.6, 1824.6, 1447.2],
1008
- ["2023-07/2024-06", 1666.0, 1832.8, 1451.7],
1009
- ["2023-10/2024-09", 1645.3, 1799.6, 1447.2],
1010
- ["2024", 1686.6, 1850.7, 1474.1],
1011
- ],
1012
- 'informal_periodo': [
1013
- # No hay datos num茅ricos espec铆ficos, solo inferencias de gr谩ficos.
1014
- ],
1015
- 'actividad_trimestral': [
1016
- ["2024-Q3",None,None,None]
1017
- ],
1018
- 'poblacion_ocupada': [
1019
- ["2022-Q2", 158.2, 86.6, 71.6],
1020
- ["2023-Q2", 161.5, 89.9, 71.6],
1021
- ["2023-Q3", 166.0, 91.6, 74.5],
1022
- ["2024-Q2", 165.4, 91.7, 73.6],
1023
- ["2024-Q3", 167.0, 93.5, 73.6],
1024
- ]
1025
- },
1026
- 'Tarapoto': {
1027
- 'desempleo_trimestral': [
1028
- ["2022-Q1", 3.5, None, None],
1029
- ["2022-Q2", 2.1, None, None],
1030
- ["2022-Q3", 2.2, None, None],
1031
- ["2022-Q4", 2.5, None, None],
1032
- ["2023-Q1", 4.7, 4.4, 5.2], # Hay dos valores para hombres y mujeres
1033
- ["2023-Q2", 4.6, 3.8, 5.6], # Hay dos valores para hombres y mujeres
1034
- ["2023-Q3", 4.6, 5.2, 3.8], # Hay dos valores para hombres y mujeres
1035
- ["2023-Q4", 4.4, 3.9, 5.1],
1036
- ["2024-Q1", 5.8, 6.1, 5.4],
1037
- ["2024-Q2", 5.0, 4.9, 5.2],
1038
- ["2024-Q3", 4.0, 3.5, 4.7],
1039
- ["2024-Q4", 2.8, 2.0, 4.0],
1040
- ],
1041
- 'ingresos_periodo': [
1042
- ["2023-04/2024-03", 1903.9, 2136.1, 1583.3],
1043
- ["2023-07/2024-06", 1928.3, 2163.4, 1608.5],
1044
- ["2023-10/2024-09", 1981.4, 2214.1, 1661.9],
1045
- ["2024", 2021.5, 2265.3, 1684.8],
1046
- ["2022-04/2023-03",1863.4,2059.1,1580.5],
1047
- ["2022-07/2023-06",1852.9,2051.5,1565.0],
1048
- ["2022-10/2023-09",1863.1,2072.9,1560.7],
1049
- ["2023",1893.2,2114.3,1579.0]
1050
- ],
1051
- 'informal_periodo': [
1052
- # No hay datos num茅ricos espec铆ficos, solo inferencias de gr谩ficos.
1053
- ],
1054
- 'actividad_trimestral': [
1055
- ###
1056
- ["2024-Q3", 72.2, None, None],
1057
- ],
1058
- 'poblacion_ocupada': [
1059
- ["2022-Q1", 87.8, 51.9, 35.8],
1060
- ["2023-Q1", 87.0, 50.9, 36.1],
1061
- ]
1062
- },
1063
- 'Trujillo': {
1064
- 'desempleo_trimestral': [
1065
- ["2022-Q1", 6.7, None, None],
1066
- ["2022-Q2", 3.9, None, None],
1067
- ["2022-Q3", 3.6, None, None],
1068
- ["2022-Q4", 3.9, None, None],
1069
- ["2023-Q1", 8.2, 5.3, 11.5],
1070
- ["2023-Q2", 7.1, 5.6, 8.8],
1071
- ["2023-Q3", 5.6, 3.5, 7.8],
1072
- ["2023-Q4", 5.3, 4.0, 6.8],
1073
- ["2024-Q1", 5.7, 4.7, 6.9],
1074
- ["2024-Q2", 5.0, 3.2, 7.1],
1075
- ["2024-Q3", 3.6, 2.1, 5.4],
1076
- ["2024-Q4", 3.8, 2.7, 5.0],
1077
- ],
1078
- 'ingresos_periodo': [
1079
- ["2022-04/2023-03", 1845.8, 2147.2, 1464.1],
1080
- ["2022-07/2023-06", 1857.0, 2151.1, 1489.6],
1081
- ["2022-10/2023-09", 1909.2, 2215.3, 1530.1],
1082
- ["2023", 1975.4, 2298.1, 1586.4],
1083
- ["2023-04/2024-03", 1987.4, 2319.0, 1592.1],
1084
- ["2023-07/2024-06", 2012.6, 2340.0, 1614.7],
1085
- ["2023-10/2024-09", 2013.9, 2304.1, 1654.2],
1086
- ["2024", 1989.7, 2255.1, 1656.6],
1087
- ],
1088
- 'informal_periodo': [
1089
- # No hay datos num茅ricos espec铆ficos, solo inferencias de gr谩ficos.
1090
- ],
1091
- 'actividad_trimestral': [
1092
- ["2023-Q3",None,None,None],
1093
- ["2024-Q3",69.1,None,None]
1094
- ],
1095
- 'poblacion_ocupada': [
1096
- ["2022-Q1", 490.8, 266.5, 224.2],
1097
- ["2022-Q3", 505.0, 275.5, 229.5],
1098
- ["2023-Q1", 542.4, 289.2, 253.3],
1099
- ["2023-Q2", 500.1, 266.9, 233.2],
1100
- ["2023-Q3", 542.4, 289.2, 253.3],
1101
- ["2024-Q2", 515.9, 282.6, 233.3],
1102
- ["2024-Q3", 536.0, 294.9, 241.0],
1103
- ]
1104
- },
1105
- 'Tumbes': {
1106
- 'desempleo_trimestral': [
1107
- ["2023-Q1", 6.3, 4.8, 8.4],
1108
- ["2023-Q2", 5.7, 4.3, 7.7],
1109
- ["2023-Q3", 5.2, 4.8, 5.9],
1110
- ["2023-Q4", 5.9, 4.8, 7.7],
1111
- ["2024-Q1", 6.7, 4.7, 9.6],
1112
- ["2024-Q2", 7.0, 5.7, 8.8],
1113
- ["2024-Q3", 7.4, 5.1, 10.9],
1114
- ["2024-Q4", 6.9, 6.5, 7.4],
1115
- ],
1116
- 'ingresos_periodo': [
1117
- ["2022-04/2023-03", 1554.9, 1663.3, 1376.7],
1118
- ["2022-07/2023-06", 1590.2, 1710.0, 1395.6],
1119
- ["2022-10/2023-09", 1623.7, 1765.0, 1397.3],
1120
- ["2023", 1640.7, 1791.0, 1401.3],
1121
- ["2023-04/2024-03", 1654.5, 1809.0, 1409.6],
1122
- ["2023-07/2024-06", 1701.0, 1853.8, 1464.9],
1123
- ["2023-10/2024-09", 1732.5, 1867.3, 1520.9],
1124
- ["2024", 1779.2, 1918.3, 1557.7],
1125
- ],
1126
- 'informal_periodo': [
1127
- ["2022-04/2023-03", 68.6, 70.2, 66.1],
1128
- ["2024",None,61.5,68.5]
1129
- ],
1130
- 'actividad_trimestral': [
1131
- ["2023-Q3",69.4,None,None],
1132
- ["2024-Q1",67.2,None,None],
1133
- ["2024-Q3",68.5,None,None]
1134
- ],
1135
- 'poblacion_ocupada': [
1136
- ["2023-Q1", 52.5, 31.6, 20.9],
1137
- ["2023-Q2", 52.1, 31.6, 20.5],
1138
- ]
1139
- },
1140
- 'Juliaca': {
1141
- 'desempleo_trimestral': [
1142
- ["2023-Q4", 6.3, 6.3, 6.3],
1143
- ["2024-Q4", 7.6, 7.6, 7.6],
1144
- ],
1145
- 'ingresos_periodo': [
1146
- ["2023", 1298.6, 1638.7, 899.9],
1147
- ["2024", 1298.6, 1638.7, 899.9]
1148
- ],
1149
- 'informal_periodo': [
1150
- # No hay datos num茅ricos espec铆ficos, solo inferencias de gr谩ficos.
1151
- ],
1152
- 'actividad_trimestral': [],
1153
- 'poblacion_ocupada': []
1154
- }
1155
- }
1156
-
1157
-
1158
- #DATA
1159
-
1160
-
1161
-
1162
- plt.rcParams['figure.figsize'] = (14, 9)
1163
- plt.rcParams['font.size'] = 13
1164
- plt.rcParams['font.family'] = 'sans-serif'
1165
- plt.style.use('seaborn-v0_8-whitegrid')
1166
 
1167
  COLORES = {
1168
  'Total': '#2C3E50',
1169
  'Hombres': '#3498DB',
1170
  'Mujeres': '#E74C3C',
1171
- 'Brecha': '#8E44AD',
1172
- 'Fondo': '#F8F9F9'
1173
  }
1174
 
1175
  def normalizar_nombres_ciudades(nombre):
@@ -1184,388 +24,225 @@ def normalizar_nombres_ciudades(nombre):
1184
  'Pura': 'Piura',
1185
  'Posalipa': 'Pucallpa',
1186
  'Tagapito': 'Talara',
1187
- 'Juliana': 'Juliaca'
 
 
 
1188
  }
1189
  return correcciones.get(nombre, nombre)
1190
 
1191
- def ordenar_trimestres(df, col_fecha='Trimestre'):
1192
- df = df.copy()
1193
- if col_fecha == 'Trimestre':
1194
- fechas = []
1195
- for t in df[col_fecha]:
1196
- if 'Q' in t:
1197
- a帽o = t.split('-')[0]
1198
- trimestre = t.split('-')[1]
1199
- mes = {'Q1': '03', 'Q2': '06', 'Q3': '09', 'Q4': '12'}[trimestre]
1200
- fechas.append(f"{a帽o}-{mes}")
1201
- else:
1202
- fechas.append(f"{t}-01")
1203
- df['fecha_orden'] = pd.to_datetime(fechas, format='%Y-%m')
1204
- else:
1205
- fechas = []
1206
- for p in df[col_fecha]:
1207
- if '/' in p:
1208
- fechas.append(p.split('/')[0])
1209
- else:
1210
- fechas.append(f"{p}-01")
1211
- df['fecha_orden'] = pd.to_datetime(fechas, format='%Y-%m', errors='coerce')
1212
- df = df.sort_values('fecha_orden')
1213
- return df
1214
-
1215
- def calcular_rango_y(df, categorias, padding=0.15):
1216
- valores = df[categorias].values.flatten()
1217
- valores = valores[~np.isnan(valores)]
1218
- if len(valores) == 0:
1219
- return (0, 1)
1220
- min_val = np.nanmin(valores)
1221
- max_val = np.nanmax(valores)
1222
- rango = max_val - min_val
1223
- return (max(0, min_val - rango*padding), max_val + rango*padding)
1224
-
1225
- def graficar_datos_mejorados(df, titulo, subtitulo, ylabel, col_fecha='Trimestre', mostrar_valores=True, formato_valores='.1f'):
1226
- fig, ax = plt.subplots(figsize=(14, 8))
1227
- ax.set_facecolor(COLORES['Fondo'])
1228
- fig.patch.set_facecolor(COLORES['Fondo'])
1229
- ax.grid(axis='y', linestyle='--', alpha=0.7)
1230
-
1231
- categorias = df.columns[1:4]
1232
- x_indices = np.arange(len(df))
1233
- ylim = calcular_rango_y(df, categorias)
1234
-
1235
- for categoria in categorias:
1236
- if categoria in df.columns and not df[categoria].isna().all():
1237
- y_vals = df[categoria].values
1238
- valid_mask = ~np.isnan(y_vals)
1239
-
1240
- ax.plot(x_indices[valid_mask], y_vals[valid_mask],
1241
- marker='o', linewidth=3, markersize=8,
1242
- label=categoria, color=COLORES[categoria])
1243
 
1244
- if mostrar_valores:
1245
- for i, valor in zip(x_indices[valid_mask], y_vals[valid_mask]):
1246
- offset = 0.2 if categoria == 'Hombres' else -0.8 if categoria == 'Mujeres' else 0
1247
- ax.annotate(f'{valor:{formato_valores}}',
1248
- xy=(i, valor),
1249
- xytext=(0, 5 + offset),
1250
- textcoords='offset points',
1251
- ha='center', va='bottom',
1252
- fontsize=10, fontweight='bold',
1253
- color=COLORES[categoria],
1254
- bbox=dict(boxstyle='round,pad=0.3', fc='white', alpha=0.7))
1255
-
1256
- ax.set_title(titulo, fontsize=18, fontweight='bold', pad=20)
1257
- plt.figtext(0.5, 0.01, subtitulo, ha='center', fontsize=12, fontstyle='italic')
1258
- ax.set_ylabel(ylabel, fontsize=14, fontweight='bold')
1259
- ax.set_xticks(x_indices)
1260
- ax.set_xticklabels(df[col_fecha].astype(str), rotation=45, ha='right')
1261
- ax.set_ylim(ylim)
1262
-
1263
- for spine in ['top', 'right']:
1264
- ax.spines[spine].set_visible(False)
1265
-
1266
- legend = ax.legend(fontsize=12, frameon=True, framealpha=0.9,
1267
- facecolor='white', edgecolor='lightgrey',
1268
- loc='upper right', bbox_to_anchor=(0.98, 0.98))
1269
- plt.tight_layout(rect=[0, 0.03, 1, 1])
1270
- return fig
1271
-
1272
- def generar_analisis_global():
1273
- figuras = []
1274
- estilo_comun = {
1275
- 'marker': 'o',
1276
- 'linewidth': 2,
1277
- 'markersize': 6,
1278
- 'alpha': 0.8
1279
- }
1280
-
1281
- # Gr谩fico de Desempleo Global
1282
- fig_desempleo = Figure(figsize=(16, 10))
1283
- ax_desempleo = fig_desempleo.add_subplot(111)
1284
- for ciudad, datos in cities_data.items():
1285
- nombre = normalizar_nombres_ciudades(ciudad)
1286
- df = ordenar_trimestres(pd.DataFrame(datos['desempleo_trimestral'],
1287
- columns=["Trimestre", "Total", "Hombres", "Mujeres"]))
1288
- if not df.empty:
1289
- ax_desempleo.plot(df['fecha_orden'], df['Total'],
1290
- label=nombre, **estilo_comun)
1291
 
1292
- ax_desempleo.set_title('TASA DE DESEMPLEO - COMPARATIVA ENTRE CIUDADES',
1293
- fontsize=18, fontweight='bold', pad=20)
1294
- ax_desempleo.set_ylabel('Tasa (%)', fontsize=14)
1295
- ax_desempleo.grid(True, linestyle='--', alpha=0.5)
1296
- ax_desempleo.xaxis.set_major_locator(mdates.YearLocator())
1297
- ax_desempleo.xaxis.set_major_formatter(mdates.DateFormatter('%Y'))
 
 
 
 
 
1298
 
1299
- handles, labels = ax_desempleo.get_legend_handles_labels()
1300
- leg = fig_desempleo.legend(handles, labels,
1301
- loc='upper center',
1302
- bbox_to_anchor=(0.5, -0.12),
1303
- ncol=5,
1304
- fontsize=10,
1305
- frameon=True,
1306
- fancybox=True,
1307
- shadow=True,
1308
- title='Ciudades',
1309
- title_fontsize='12')
1310
- fig_desempleo.tight_layout(rect=[0, 0.1, 1, 0.95])
1311
- figuras.append(fig_desempleo)
1312
-
1313
- # Gr谩fico de Ingresos Global
1314
- fig_ingresos = Figure(figsize=(16, 10))
1315
- ax_ingresos = fig_ingresos.add_subplot(111)
1316
- for ciudad, datos in cities_data.items():
1317
- nombre = normalizar_nombres_ciudades(ciudad)
1318
- df = ordenar_trimestres(pd.DataFrame(datos['ingresos_periodo'],
1319
- columns=["Periodo", "Total", "Hombres", "Mujeres"]),
1320
- 'Periodo')
1321
- if not df.empty:
1322
- ax_ingresos.plot(df['fecha_orden'], df['Total'],
1323
- label=nombre, **estilo_comun)
1324
 
1325
- ax_ingresos.set_title('INGRESOS PROMEDIO - COMPARATIVA ENTRE CIUDADES',
1326
- fontsize=18, fontweight='bold', pad=20)
1327
- ax_ingresos.set_ylabel('Ingresos (Soles)', fontsize=14)
1328
- ax_ingresos.grid(True, linestyle='--', alpha=0.5)
1329
- ax_ingresos.xaxis.set_major_locator(mdates.YearLocator())
1330
- ax_ingresos.xaxis.set_major_formatter(mdates.DateFormatter('%Y'))
1331
 
1332
- handles, labels = ax_ingresos.get_legend_handles_labels()
1333
- leg = fig_ingresos.legend(handles, labels,
1334
- loc='upper center',
1335
- bbox_to_anchor=(0.5, -0.12),
1336
- ncol=5,
1337
- fontsize=10,
1338
- frameon=True,
1339
- fancybox=True,
1340
- shadow=True,
1341
- title='Ciudades',
1342
- title_fontsize='12')
1343
- fig_ingresos.tight_layout(rect=[0, 0.1, 1, 0.95])
1344
- figuras.append(fig_ingresos)
1345
 
1346
- # Gr谩fico de Brecha Salarial Global
1347
- fig_brecha = Figure(figsize=(16, 10))
1348
- ax_brecha = fig_brecha.add_subplot(111)
1349
- for ciudad, datos in cities_data.items():
1350
  nombre = normalizar_nombres_ciudades(ciudad)
1351
- df = ordenar_trimestres(pd.DataFrame(datos['ingresos_periodo'],
1352
- columns=["Periodo", "Total", "Hombres", "Mujeres"]),
1353
- 'Periodo')
1354
- if not df.empty and 'Hombres' in df.columns and 'Mujeres' in df.columns:
1355
- df['Brecha'] = (df['Hombres'] - df['Mujeres']) / df['Hombres'] * 100
1356
- ax_brecha.plot(df['fecha_orden'], df['Brecha'],
1357
- label=nombre, **estilo_comun)
1358
 
1359
- ax_brecha.set_title('BRECHA SALARIAL DE G脡NERO - COMPARATIVA ENTRE CIUDADES',
1360
- fontsize=18, fontweight='bold', pad=20)
1361
- ax_brecha.set_ylabel('Brecha (%)', fontsize=14)
1362
- ax_brecha.grid(True, linestyle='--', alpha=0.5)
1363
- ax_brecha.xaxis.set_major_locator(mdates.YearLocator())
1364
- ax_brecha.xaxis.set_major_formatter(mdates.DateFormatter('%Y'))
1365
 
1366
- handles, labels = ax_brecha.get_legend_handles_labels()
1367
- leg = fig_brecha.legend(handles, labels,
1368
- loc='upper center',
1369
- bbox_to_anchor=(0.5, -0.12),
1370
- ncol=5,
1371
- fontsize=10,
1372
- frameon=True,
1373
- fancybox=True,
1374
- shadow=True,
1375
- title='Ciudades',
1376
- title_fontsize='12')
1377
- fig_brecha.tight_layout(rect=[0, 0.1, 1, 0.95])
1378
- figuras.append(fig_brecha)
1379
-
1380
- return figuras
1381
-
1382
- def load_data(city):
1383
- data = cities_data[city]
1384
- return [
1385
- data['desempleo_trimestral'],
1386
- data['ingresos_periodo'],
1387
- data['informal_periodo'],
1388
- data['actividad_trimestral'],
1389
- data['poblacion_ocupada']
1390
- ]
1391
 
1392
- def generate_plots(desempleo_df, ingresos_df, informal_df, actividad_df, poblacion_df):
1393
- dfs = {
1394
- 'desempleo': pd.DataFrame(desempleo_df, columns=["Trimestre", "Total", "Hombres", "Mujeres"]),
1395
- 'ingresos': pd.DataFrame(ingresos_df, columns=["Periodo", "Total", "Hombres", "Mujeres"]),
1396
- 'informal': pd.DataFrame(informal_df, columns=["Periodo", "Total", "Hombres", "Mujeres"]),
1397
- 'actividad': pd.DataFrame(actividad_df, columns=["Trimestre", "Total", "Hombres", "Mujeres"]),
1398
- 'poblacion': pd.DataFrame(poblacion_df, columns=["Trimestre", "Total", "Hombres", "Mujeres"])
1399
  }
1400
-
1401
- for key in dfs:
1402
- for col in ["Total", "Hombres", "Mujeres"]:
1403
- dfs[key][col] = pd.to_numeric(dfs[key][col], errors='coerce')
1404
-
1405
- for key in dfs:
1406
- dfs[key] = ordenar_trimestres(dfs[key], 'Trimestre' if key in ['desempleo', 'actividad', 'poblacion'] else 'Periodo')
1407
-
1408
- figs = []
1409
-
1410
- # Radar Plot
1411
- problem_metrics = {
1412
- 'Desempleo': dfs['desempleo']['Total'].iloc[-1] if not dfs['desempleo'].empty else 0,
1413
- 'Informalidad': dfs['informal']['Total'].iloc[-1] if not dfs['informal'].empty else 0,
1414
- 'Brecha Salarial': (
1415
- (dfs['ingresos']['Hombres'].iloc[-1] - dfs['ingresos']['Mujeres'].iloc[-1]) /
1416
- dfs['ingresos']['Hombres'].iloc[-1] * 100
1417
- if not dfs['ingresos'].empty and pd.notna(dfs['ingresos']['Hombres'].iloc[-1]) and pd.notna(dfs['ingresos']['Mujeres'].iloc[-1]) else 0
 
 
 
 
 
 
 
1418
  ),
1419
- 'Actividad': dfs['actividad']['Total'].iloc[-1] if not dfs['actividad'].empty else 0
1420
- }
1421
-
1422
- categories = list(problem_metrics.keys())
1423
- values = list(problem_metrics.values())
1424
- angles = np.linspace(0, 2*np.pi, len(categories), endpoint=False).tolist()
1425
- values += values[:1]
1426
- angles += angles[:1]
1427
-
1428
- fig_radar, ax_radar = plt.subplots(figsize=(10, 10), subplot_kw=dict(polar=True))
1429
- ax_radar.fill(angles, values, color=COLORES['Brecha'], alpha=0.2)
1430
- ax_radar.set_theta_offset(np.pi/2)
1431
- ax_radar.set_theta_direction(-1)
1432
- ax_radar.set_thetagrids(np.degrees(angles[:-1]), labels=categories)
1433
- ax_radar.set_rlabel_position(0)
1434
- plt.yticks([20,40,60,80], ["20%","40%","60%","80%"], color="grey", size=10)
1435
- plt.ylim(0,100)
1436
- ax_radar.set_title(f'RADAR DE PROBLEM脕TICAS LABORALES\n{dfs["desempleo"]["Trimestre"].iloc[-1]}',
1437
- pad=20, fontsize=14, fontweight='bold')
1438
- figs.append(fig_radar)
1439
-
1440
- # Gr谩ficos principales
1441
- figs.append(graficar_datos_mejorados(dfs['desempleo'], 'TASA DE DESEMPLEO', 'Evoluci贸n por g茅nero', 'Tasa (%)'))
1442
- figs.append(graficar_datos_mejorados(dfs['ingresos'], 'INGRESOS PROMEDIO', 'Por per铆odo y g茅nero', 'Ingreso (soles)', col_fecha='Periodo', formato_valores='.0f'))
1443
- figs.append(graficar_datos_mejorados(dfs['informal'], 'TASA DE INFORMALIDAD', 'Por per铆odo', 'Tasa (%)', col_fecha='Periodo'))
1444
- figs.append(graficar_datos_mejorados(dfs['actividad'], 'TASA DE ACTIVIDAD', 'Participaci贸n econ贸mica', 'Tasa (%)'))
1445
- figs.append(graficar_datos_mejorados(dfs['poblacion'], 'POBLACI脫N OCUPADA', 'En miles de personas', 'Poblaci贸n (miles)'))
1446
 
1447
- # Brecha Salarial
1448
- ingresos = dfs['ingresos']
1449
- brecha = []
1450
- for h, m in zip(ingresos['Hombres'], ingresos['Mujeres']):
1451
- if pd.notna(h) and pd.notna(m) and h != 0:
1452
- brecha.append((h-m)/h*100)
1453
- else:
1454
- brecha.append(np.nan)
 
 
 
 
 
 
1455
 
1456
- fig_brecha, ax_brecha = plt.subplots(figsize=(14,8))
1457
- valid_indices = [i for i, b in enumerate(brecha) if pd.notna(b)]
1458
- valid_periods = [str(ingresos['Periodo'].iloc[i]) for i in valid_indices]
1459
- valid_brecha = [brecha[i] for i in valid_indices]
 
 
 
 
 
1460
 
1461
- if valid_periods:
1462
- bars = ax_brecha.bar(valid_periods, valid_brecha, color=COLORES['Brecha'])
1463
- for bar in bars:
1464
- height = bar.get_height()
1465
- ax_brecha.text(bar.get_x() + bar.get_width()/2., height + 0.5,
1466
- f'{height:.1f}%', ha='center', va='bottom',
1467
- fontsize=10, fontweight='bold')
1468
- ax_brecha.set_title('BRECHA SALARIAL DE G脡NERO', fontsize=18, pad=20)
1469
- ax_brecha.set_ylabel('Brecha (%)', fontsize=14)
1470
- ax_brecha.grid(axis='y', linestyle='--', alpha=0.7)
 
 
 
 
 
 
 
 
 
1471
  figs.append(fig_brecha)
1472
-
1473
  return figs
1474
 
1475
- with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue"), css=".gradio-container {background-color: #F8F9F9}") as app:
1476
- gr.Markdown("# 馃搳 Dashboard de Indicadores Laborales por G茅nero")
1477
- gr.Markdown("Analiza los principales indicadores del mercado laboral con perspectiva de g茅nero")
1478
-
1479
  with gr.Row():
1480
- city = gr.Dropdown(
1481
  list(cities_data.keys()),
1482
- label="Seleccione una Ciudad",
1483
  value="Chimbote",
1484
- info="Elija la ciudad para visualizar sus datos"
1485
  )
1486
-
1487
- with gr.Tab("Datos"):
1488
- with gr.Accordion("Tasa de Desempleo", open=True):
1489
- desempleo_df = gr.Dataframe(
1490
- headers=["Trimestre", "Total", "Hombres", "Mujeres"],
1491
- datatype=["str", "number", "number", "number"],
1492
- label="Datos de Desempleo"
1493
- )
1494
- with gr.Accordion("Ingresos", open=False):
1495
- ingresos_df = gr.Dataframe(
1496
- headers=["Periodo", "Total", "Hombres", "Mujeres"],
1497
- datatype=["str", "number", "number", "number"],
1498
- label="Datos de Ingresos"
1499
- )
1500
- with gr.Accordion("Informalidad", open=False):
1501
- informal_df = gr.Dataframe(
1502
- headers=["Periodo", "Total", "Hombres", "Mujeres"],
1503
- datatype=["str", "number", "number", "number"],
1504
- label="Datos de Informalidad"
1505
- )
1506
- with gr.Accordion("Actividad Econ贸mica", open=False):
1507
- actividad_df = gr.Dataframe(
1508
- headers=["Trimestre", "Total", "Hombres", "Mujeres"],
1509
- datatype=["str", "number", "number", "number"],
1510
- label="Datos de Actividad"
1511
- )
1512
- with gr.Accordion("Poblaci贸n Ocupada", open=False):
1513
- poblacion_df = gr.Dataframe(
1514
- headers=["Trimestre", "Total", "Hombres", "Mujeres"],
1515
- datatype=["str", "number", "number", "number"],
1516
- label="Datos de Poblaci贸n Ocupada"
1517
- )
1518
-
1519
- btn = gr.Button("Generar Visualizaciones", variant="primary")
1520
-
1521
- with gr.Tab("Visualizaciones"):
1522
- with gr.Row():
1523
- radar_plot = gr.Plot(label="Radar de Problem谩ticas Laborales")
1524
- with gr.Row():
1525
- desempleo_plot = gr.Plot(label="Tasa de Desempleo")
1526
  with gr.Row():
1527
- ingresos_plot = gr.Plot(label="Ingresos Promedio")
1528
- brecha_salarial_plot = gr.Plot(label="Brecha Salarial de G茅nero")
1529
  with gr.Row():
1530
- informalidad_plot = gr.Plot(label="Tasa de Informalidad")
1531
- actividad_plot = gr.Plot(label="Tasa de Actividad")
1532
  with gr.Row():
1533
- poblacion_plot = gr.Plot(label="Poblaci贸n Ocupada")
1534
-
1535
- with gr.Tab("An谩lisis Global"):
1536
- gr.Markdown("## An谩lisis Comparativo entre Ciudades")
1537
- global_btn = gr.Button("Generar An谩lisis Global", variant="primary")
1538
- with gr.Row():
1539
- global_desempleo_plot = gr.Plot(label="Comparativa de Desempleo")
1540
  with gr.Row():
1541
- global_ingresos_plot = gr.Plot(label="Comparativa de Ingresos")
1542
  with gr.Row():
1543
- global_brecha_plot = gr.Plot(label="Comparativa de Brecha Salarial")
1544
-
1545
- city.change(
1546
- fn=load_data,
1547
- inputs=city,
1548
- outputs=[desempleo_df, ingresos_df, informal_df, actividad_df, poblacion_df]
1549
- )
1550
-
1551
- btn.click(
1552
- fn=generate_plots,
1553
- inputs=[desempleo_df, ingresos_df, informal_df, actividad_df, poblacion_df],
1554
- outputs=[
1555
- radar_plot,
1556
- desempleo_plot,
1557
- ingresos_plot,
1558
- informalidad_plot,
1559
- actividad_plot,
1560
- poblacion_plot,
1561
- brecha_salarial_plot
 
 
 
1562
  ]
1563
- )
1564
-
1565
- global_btn.click(
1566
- fn=generar_analisis_global,
1567
- inputs=[],
1568
- outputs=[global_desempleo_plot, global_ingresos_plot, global_brecha_plot]
1569
- )
1570
 
1571
  app.launch(debug=True)
 
1
  import pandas as pd
 
2
  import numpy as np
3
+ import plotly.express as px
4
+ import plotly.graph_objects as go
 
5
  import gradio as gr
6
+ from datetime import datetime
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
  COLORES = {
9
  'Total': '#2C3E50',
10
  'Hombres': '#3498DB',
11
  'Mujeres': '#E74C3C',
12
+ 'Brecha': '#8E44AD'
 
13
  }
14
 
15
  def normalizar_nombres_ciudades(nombre):
 
24
  'Pura': 'Piura',
25
  'Posalipa': 'Pucallpa',
26
  'Tagapito': 'Talara',
27
+ 'Juliana': 'Juliaca',
28
+ 'Chimbote': 'Chimbote',
29
+ 'Arequipa': 'Arequipa',
30
+ 'Trujillo': 'Trujillo'
31
  }
32
  return correcciones.get(nombre, nombre)
33
 
34
+ def procesar_dataframe(df, cols):
35
+ return pd.DataFrame(df, columns=cols).apply(pd.to_numeric, errors='coerce', axis=1)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
+ def crear_grafico_lineas(df, titulo, eje_y, formato=None):
38
+ fig = go.Figure()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
 
40
+ for col in ['Total', 'Hombres', 'Mujeres']:
41
+ if col in df.columns:
42
+ fig.add_trace(go.Scatter(
43
+ x=df['Periodo'],
44
+ y=df[col],
45
+ name=col,
46
+ mode='lines+markers',
47
+ line=dict(color=COLORES[col], width=3),
48
+ marker=dict(size=8),
49
+ hovertemplate=f'<b>{col}</b>: %{{y:{formato or ".2f"}}}<extra></extra>'
50
+ ))
51
 
52
+ fig.update_layout(
53
+ title=dict(text=titulo, x=0.5, font=dict(size=20)),
54
+ yaxis_title=eje_y,
55
+ xaxis_title='Periodo',
56
+ hovermode='x unified',
57
+ template='plotly_white',
58
+ legend=dict(
59
+ orientation="h",
60
+ yanchor="bottom",
61
+ y=1.02,
62
+ xanchor="right",
63
+ x=1
64
+ )
65
+ )
 
 
 
 
 
 
 
 
 
 
 
66
 
67
+ if formato:
68
+ fig.update_layout(yaxis_tickformat=formato)
 
 
 
 
69
 
70
+ return fig
 
 
 
 
 
 
 
 
 
 
 
 
71
 
72
+ def analisis_comparativo_desempleo():
73
+ datos = []
74
+
75
+ for ciudad, data in cities_data.items():
76
  nombre = normalizar_nombres_ciudades(ciudad)
77
+ df = pd.DataFrame(data['desempleo_trimestral'],
78
+ columns=["Trimestre", "Total", "Hombres", "Mujeres"])
79
+ ultimo_valor = df['Total'].iloc[-1] if not df.empty else None
80
+ if ultimo_valor:
81
+ datos.append({'Ciudad': nombre, 'Desempleo': ultimo_valor})
 
 
82
 
83
+ df_comparativo = pd.DataFrame(datos).sort_values('Desempleo', ascending=False)
 
 
 
 
 
84
 
85
+ fig = px.bar(df_comparativo,
86
+ x='Ciudad',
87
+ y='Desempleo',
88
+ color='Desempleo',
89
+ color_continuous_scale='Bluered',
90
+ text_auto='.1f%',
91
+ title='Comparaci贸n de Tasa de Desempleo entre Ciudades')
92
+
93
+ fig.update_layout(
94
+ xaxis_title='',
95
+ yaxis_title='Tasa de Desempleo (%)',
96
+ coloraxis_showscale=False,
97
+ xaxis={'categoryorder':'total descending'},
98
+ hoverlabel=dict(bgcolor="white", font_size=12),
99
+ height=600
100
+ )
101
+
102
+ fig.update_traces(textfont_size=12, textangle=0, textposition="outside")
103
+ return fig
 
 
 
 
 
 
104
 
105
+ def crear_radar_plot(dfs):
106
+ metricas = {
107
+ 'Desempleo': dfs['desempleo']['Total'].iloc[-1],
108
+ 'Informalidad': dfs['informal']['Total'].iloc[-1],
109
+ 'Brecha Salarial': ((dfs['ingresos']['Hombres'].iloc[-1] - dfs['ingresos']['Mujeres'].iloc[-1]) /
110
+ dfs['ingresos']['Hombres'].iloc[-1]) * 100,
111
+ 'Actividad': dfs['actividad']['Total'].iloc[-1]
112
  }
113
+
114
+ fig = go.Figure()
115
+
116
+ fig.add_trace(go.Scatterpolar(
117
+ r=list(metricas.values()) + [metricas['Desempleo']],
118
+ theta=list(metricas.keys()) + ['Desempleo'],
119
+ fill='toself',
120
+ fillcolor='rgba(142, 68, 173, 0.2)',
121
+ line=dict(color=COLORES['Brecha'], width=2),
122
+ name='Indicadores'
123
+ ))
124
+
125
+ fig.update_layout(
126
+ polar=dict(
127
+ radialaxis=dict(
128
+ visible=True,
129
+ range=[0, 100],
130
+ tickfont=dict(size=12),
131
+ tickformat='.0f%'
132
+ ),
133
+ angularaxis=dict(
134
+ rotation=90,
135
+ direction='clockwise',
136
+ tickfont=dict(size=14)
137
+ )
138
  ),
139
+ title=dict(text='Radar de Indicadores Laborales', x=0.5, font=dict(size=20)),
140
+ showlegend=False,
141
+ height=600
142
+ )
143
+
144
+ return fig
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145
 
146
+ def generar_analisis_global():
147
+ figs = []
148
+
149
+ # Gr谩fico comparativo de desempleo
150
+ figs.append(analisis_comparativo_desempleo())
151
+
152
+ # Gr谩fico de tendencia de ingresos
153
+ datos_ingresos = []
154
+ for ciudad, data in cities_data.items():
155
+ nombre = normalizar_nombres_ciudades(ciudad)
156
+ df = pd.DataFrame(data['ingresos_periodo'],
157
+ columns=["Periodo", "Total", "Hombres", "Mujeres"])
158
+ df['Ciudad'] = nombre
159
+ datos_ingresos.append(df)
160
 
161
+ df_ingresos = pd.concat(datos_ingresos)
162
+ fig_ingresos = px.line(df_ingresos,
163
+ x='Periodo',
164
+ y='Total',
165
+ color='Ciudad',
166
+ title='Evoluci贸n de Ingresos por Ciudad',
167
+ markers=True)
168
+ fig_ingresos.update_layout(height=600)
169
+ figs.append(fig_ingresos)
170
 
171
+ # Gr谩fico de brecha salarial
172
+ datos_brecha = []
173
+ for ciudad, data in cities_data.items():
174
+ nombre = normalizar_nombres_ciudades(ciudad)
175
+ df = pd.DataFrame(data['ingresos_periodo'],
176
+ columns=["Periodo", "Total", "Hombres", "Mujeres"])
177
+ df['Brecha'] = (df['Hombres'] - df['Mujeres']) / df['Hombres'] * 100
178
+ df['Ciudad'] = nombre
179
+ datos_brecha.append(df)
180
+
181
+ df_brecha = pd.concat(datos_brecha)
182
+ fig_brecha = px.bar(df_brecha,
183
+ x='Periodo',
184
+ y='Brecha',
185
+ color='Ciudad',
186
+ barmode='group',
187
+ title='Evoluci贸n de Brecha Salarial por Ciudad',
188
+ text_auto='.1f%')
189
+ fig_brecha.update_layout(height=600)
190
  figs.append(fig_brecha)
191
+
192
  return figs
193
 
194
+ with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue"), css=".gradio-container {background-color: white}") as app:
195
+ gr.Markdown("# 馃搳 Dashboard Interactivo de Mercado Laboral")
196
+
 
197
  with gr.Row():
198
+ ciudad = gr.Dropdown(
199
  list(cities_data.keys()),
200
+ label="Seleccionar Ciudad",
201
  value="Chimbote",
202
+ interactive=True
203
  )
204
+
205
+ with gr.Tab("An谩lisis por Ciudad"):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
206
  with gr.Row():
207
+ desempleo_plot = gr.Plotly(label="Tasa de Desempleo")
208
+ ingresos_plot = gr.Plotly(label="Ingresos Promedio")
209
  with gr.Row():
210
+ informalidad_plot = gr.Plotly(label="Tasa de Informalidad")
211
+ actividad_plot = gr.Plotly(label="Tasa de Actividad")
212
  with gr.Row():
213
+ radar_plot = gr.Plotly(label="Radar de Indicadores")
214
+ brecha_plot = gr.Plotly(label="Brecha Salarial")
215
+
216
+ with gr.Tab("An谩lisis Comparativo"):
 
 
 
217
  with gr.Row():
218
+ global_desempleo = gr.Plotly(label="Comparativa de Desempleo")
219
  with gr.Row():
220
+ global_ingresos = gr.Plotly(label="Evoluci贸n de Ingresos")
221
+ global_brecha = gr.Plotly(label="Evoluci贸n de Brecha Salarial")
222
+
223
+ @app.change(inputs=ciudad, outputs=[desempleo_plot, ingresos_plot, informalidad_plot, actividad_plot, radar_plot, brecha_plot])
224
+ def actualizar_graficos(ciudad):
225
+ data = cities_data[ciudad]
226
+
227
+ dfs = {
228
+ 'desempleo': procesar_dataframe(data['desempleo_trimestral'], ["Trimestre", "Total", "Hombres", "Mujeres"]),
229
+ 'ingresos': procesar_dataframe(data['ingresos_periodo'], ["Periodo", "Total", "Hombres", "Mujeres"]),
230
+ 'informal': procesar_dataframe(data['informal_periodo'], ["Periodo", "Total", "Hombres", "Mujeres"]),
231
+ 'actividad': procesar_dataframe(data['actividad_trimestral'], ["Trimestre", "Total", "Hombres", "Mujeres"])
232
+ }
233
+
234
+ return [
235
+ crear_grafico_lineas(dfs['desempleo'], "Tasa de Desempleo", "Porcentaje (%)", ".1f"),
236
+ crear_grafico_lineas(dfs['ingresos'], "Ingresos Promedio", "Soles", ".0f"),
237
+ crear_grafico_lineas(dfs['informal'], "Tasa de Informalidad", "Porcentaje (%)", ".1f"),
238
+ crear_grafico_lineas(dfs['actividad'], "Tasa de Actividad", "Porcentaje (%)", ".1f"),
239
+ crear_radar_plot(dfs),
240
+ crear_grafico_lineas(dfs['ingresos'].assign(Brecha=lambda x: (x['Hombres'] - x['Mujeres']) / x['Hombres'] * 100),
241
+ "Brecha Salarial de G茅nero", "Porcentaje (%)", ".1f")
242
  ]
243
+
244
+ @app.click(inputs=None, outputs=[global_desempleo, global_ingresos, global_brecha])
245
+ def actualizar_analisis_global():
246
+ return generar_analisis_global()
 
 
 
247
 
248
  app.launch(debug=True)