tcapelle commited on
Commit
ba1a530
1 Parent(s): 9570030

agregar rgafico

Browse files
Files changed (3) hide show
  1. app.py +3 -3
  2. calc.ipynb +1137 -48
  3. impuestos.py +12 -0
app.py CHANGED
@@ -2,7 +2,7 @@ from pathlib import Path
2
  from types import SimpleNamespace
3
  import streamlit as st
4
 
5
- from impuestos import TRAMOS, TRAMOS_REFORMA, get_table
6
 
7
  TOPES = SimpleNamespace(arriendo=450000, cuidado=550000)
8
 
@@ -54,8 +54,8 @@ def main() -> None:
54
  total_reforma = table["Impuesto"].sum()
55
  col2.subheader(f"Total Impuesto con Reforma: ${total_reforma} ({100*(total_reforma/sueldo_bruto):.2f}\%)")
56
 
57
-
58
- # st.plotly_chart()
59
 
60
  if __name__ == "__main__":
61
  st.set_page_config(
 
2
  from types import SimpleNamespace
3
  import streamlit as st
4
 
5
+ from impuestos import TRAMOS, TRAMOS_REFORMA, get_table, get_curve
6
 
7
  TOPES = SimpleNamespace(arriendo=450000, cuidado=550000)
8
 
 
54
  total_reforma = table["Impuesto"].sum()
55
  col2.subheader(f"Total Impuesto con Reforma: ${total_reforma} ({100*(total_reforma/sueldo_bruto):.2f}\%)")
56
 
57
+ st.text("En el siguiente grafico se ve claramente que la reforma empieza a tener efecto a partir de los 4 millones. Por ejemplo con 8 millones mensuales la diferencia es solo de 200000 mensual.")
58
+ st.plotly_chart(get_curve(0), use_container_width=True)
59
 
60
  if __name__ == "__main__":
61
  st.set_page_config(
calc.ipynb CHANGED
@@ -2,7 +2,7 @@
2
  "cells": [
3
  {
4
  "cell_type": "code",
5
- "execution_count": 1,
6
  "metadata": {},
7
  "outputs": [],
8
  "source": [
@@ -11,15 +11,15 @@
11
  },
12
  {
13
  "cell_type": "code",
14
- "execution_count": 2,
15
  "metadata": {},
16
  "outputs": [
17
  {
18
  "name": "stdout",
19
  "output_type": "stream",
20
  "text": [
21
- "786384 0\n",
22
- "1747440 0.04\n"
23
  ]
24
  }
25
  ],
@@ -37,16 +37,16 @@
37
  },
38
  {
39
  "cell_type": "code",
40
- "execution_count": 3,
41
  "metadata": {},
42
  "outputs": [
43
  {
44
  "data": {
45
  "text/plain": [
46
- "[786384, 1747440, 2912400, 4077360, 5242320, 6989760, 18056880, 99999999]"
47
  ]
48
  },
49
- "execution_count": 3,
50
  "metadata": {},
51
  "output_type": "execute_result"
52
  }
@@ -57,7 +57,7 @@
57
  },
58
  {
59
  "cell_type": "code",
60
- "execution_count": 18,
61
  "metadata": {},
62
  "outputs": [],
63
  "source": [
@@ -76,16 +76,16 @@
76
  },
77
  {
78
  "cell_type": "code",
79
- "execution_count": 19,
80
  "metadata": {},
81
  "outputs": [
82
  {
83
  "data": {
84
  "text/plain": [
85
- "([786384, 413616], [0, 16544])"
86
  ]
87
  },
88
- "execution_count": 19,
89
  "metadata": {},
90
  "output_type": "execute_result"
91
  }
@@ -97,7 +97,7 @@
97
  },
98
  {
99
  "cell_type": "code",
100
- "execution_count": 20,
101
  "metadata": {},
102
  "outputs": [],
103
  "source": [
@@ -106,7 +106,7 @@
106
  },
107
  {
108
  "cell_type": "code",
109
- "execution_count": 21,
110
  "metadata": {},
111
  "outputs": [],
112
  "source": [
@@ -120,7 +120,7 @@
120
  },
121
  {
122
  "cell_type": "code",
123
- "execution_count": 22,
124
  "metadata": {},
125
  "outputs": [
126
  {
@@ -155,58 +155,58 @@
155
  " <tr>\n",
156
  " <th>0</th>\n",
157
  " <td>0</td>\n",
158
- " <td>786384</td>\n",
159
- " <td>786384</td>\n",
160
  " <td>0.000</td>\n",
161
  " <td>0</td>\n",
162
  " </tr>\n",
163
  " <tr>\n",
164
  " <th>1</th>\n",
165
- " <td>786384</td>\n",
166
- " <td>1747440</td>\n",
167
- " <td>961056</td>\n",
168
  " <td>0.040</td>\n",
169
- " <td>38442</td>\n",
170
  " </tr>\n",
171
  " <tr>\n",
172
  " <th>2</th>\n",
173
- " <td>1747440</td>\n",
174
- " <td>2912400</td>\n",
175
- " <td>1164960</td>\n",
176
  " <td>0.080</td>\n",
177
- " <td>93196</td>\n",
178
  " </tr>\n",
179
  " <tr>\n",
180
  " <th>3</th>\n",
181
- " <td>2912400</td>\n",
182
- " <td>4077360</td>\n",
183
- " <td>1164960</td>\n",
184
  " <td>0.135</td>\n",
185
- " <td>157269</td>\n",
186
  " </tr>\n",
187
  " <tr>\n",
188
  " <th>4</th>\n",
189
- " <td>4077360</td>\n",
190
- " <td>5242320</td>\n",
191
- " <td>1164960</td>\n",
192
  " <td>0.230</td>\n",
193
- " <td>267940</td>\n",
194
  " </tr>\n",
195
  " <tr>\n",
196
  " <th>5</th>\n",
197
- " <td>5242320</td>\n",
198
- " <td>6989760</td>\n",
199
- " <td>1747440</td>\n",
200
  " <td>0.304</td>\n",
201
- " <td>531221</td>\n",
202
  " </tr>\n",
203
  " <tr>\n",
204
  " <th>6</th>\n",
205
- " <td>6989760</td>\n",
206
- " <td>18056880</td>\n",
207
- " <td>3010240</td>\n",
208
  " <td>0.350</td>\n",
209
- " <td>1053584</td>\n",
210
  " </tr>\n",
211
  " </tbody>\n",
212
  "</table>\n",
@@ -214,16 +214,16 @@
214
  ],
215
  "text/plain": [
216
  " Desde Hasta Monto Tasa Impuesto\n",
217
- "0 0 786384 786384 0.000 0\n",
218
- "1 786384 1747440 961056 0.040 38442\n",
219
- "2 1747440 2912400 1164960 0.080 93196\n",
220
- "3 2912400 4077360 1164960 0.135 157269\n",
221
- "4 4077360 5242320 1164960 0.230 267940\n",
222
- "5 5242320 6989760 1747440 0.304 531221\n",
223
- "6 6989760 18056880 3010240 0.350 1053584"
224
  ]
225
  },
226
- "execution_count": 22,
227
  "metadata": {},
228
  "output_type": "execute_result"
229
  }
@@ -232,6 +232,1095 @@
232
  "get_table(10000000)"
233
  ]
234
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 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  "cell_type": "code",
237
  "execution_count": null,
 
2
  "cells": [
3
  {
4
  "cell_type": "code",
5
+ "execution_count": 7,
6
  "metadata": {},
7
  "outputs": [],
8
  "source": [
 
11
  },
12
  {
13
  "cell_type": "code",
14
+ "execution_count": 8,
15
  "metadata": {},
16
  "outputs": [
17
  {
18
  "name": "stdout",
19
  "output_type": "stream",
20
  "text": [
21
+ "777000 0\n",
22
+ "1727000 0.04\n"
23
  ]
24
  }
25
  ],
 
37
  },
38
  {
39
  "cell_type": "code",
40
+ "execution_count": 9,
41
  "metadata": {},
42
  "outputs": [
43
  {
44
  "data": {
45
  "text/plain": [
46
+ "[777000, 1727000, 2878000, 4029000, 5180000, 6906000, 17842000, 99999999]"
47
  ]
48
  },
49
+ "execution_count": 9,
50
  "metadata": {},
51
  "output_type": "execute_result"
52
  }
 
57
  },
58
  {
59
  "cell_type": "code",
60
+ "execution_count": 10,
61
  "metadata": {},
62
  "outputs": [],
63
  "source": [
 
76
  },
77
  {
78
  "cell_type": "code",
79
+ "execution_count": 11,
80
  "metadata": {},
81
  "outputs": [
82
  {
83
  "data": {
84
  "text/plain": [
85
+ "([777000, 423000], [0, 16920])"
86
  ]
87
  },
88
+ "execution_count": 11,
89
  "metadata": {},
90
  "output_type": "execute_result"
91
  }
 
97
  },
98
  {
99
  "cell_type": "code",
100
+ "execution_count": 12,
101
  "metadata": {},
102
  "outputs": [],
103
  "source": [
 
106
  },
107
  {
108
  "cell_type": "code",
109
+ "execution_count": 13,
110
  "metadata": {},
111
  "outputs": [],
112
  "source": [
 
120
  },
121
  {
122
  "cell_type": "code",
123
+ "execution_count": 14,
124
  "metadata": {},
125
  "outputs": [
126
  {
 
155
  " <tr>\n",
156
  " <th>0</th>\n",
157
  " <td>0</td>\n",
158
+ " <td>777000</td>\n",
159
+ " <td>777000</td>\n",
160
  " <td>0.000</td>\n",
161
  " <td>0</td>\n",
162
  " </tr>\n",
163
  " <tr>\n",
164
  " <th>1</th>\n",
165
+ " <td>777000</td>\n",
166
+ " <td>1727000</td>\n",
167
+ " <td>950000</td>\n",
168
  " <td>0.040</td>\n",
169
+ " <td>38000</td>\n",
170
  " </tr>\n",
171
  " <tr>\n",
172
  " <th>2</th>\n",
173
+ " <td>1727000</td>\n",
174
+ " <td>2878000</td>\n",
175
+ " <td>1151000</td>\n",
176
  " <td>0.080</td>\n",
177
+ " <td>92080</td>\n",
178
  " </tr>\n",
179
  " <tr>\n",
180
  " <th>3</th>\n",
181
+ " <td>2878000</td>\n",
182
+ " <td>4029000</td>\n",
183
+ " <td>1151000</td>\n",
184
  " <td>0.135</td>\n",
185
+ " <td>155385</td>\n",
186
  " </tr>\n",
187
  " <tr>\n",
188
  " <th>4</th>\n",
189
+ " <td>4029000</td>\n",
190
+ " <td>5180000</td>\n",
191
+ " <td>1151000</td>\n",
192
  " <td>0.230</td>\n",
193
+ " <td>264730</td>\n",
194
  " </tr>\n",
195
  " <tr>\n",
196
  " <th>5</th>\n",
197
+ " <td>5180000</td>\n",
198
+ " <td>6906000</td>\n",
199
+ " <td>1726000</td>\n",
200
  " <td>0.304</td>\n",
201
+ " <td>524704</td>\n",
202
  " </tr>\n",
203
  " <tr>\n",
204
  " <th>6</th>\n",
205
+ " <td>6906000</td>\n",
206
+ " <td>17842000</td>\n",
207
+ " <td>3094000</td>\n",
208
  " <td>0.350</td>\n",
209
+ " <td>1082900</td>\n",
210
  " </tr>\n",
211
  " </tbody>\n",
212
  "</table>\n",
 
214
  ],
215
  "text/plain": [
216
  " Desde Hasta Monto Tasa Impuesto\n",
217
+ "0 0 777000 777000 0.000 0\n",
218
+ "1 777000 1727000 950000 0.040 38000\n",
219
+ "2 1727000 2878000 1151000 0.080 92080\n",
220
+ "3 2878000 4029000 1151000 0.135 155385\n",
221
+ "4 4029000 5180000 1151000 0.230 264730\n",
222
+ "5 5180000 6906000 1726000 0.304 524704\n",
223
+ "6 6906000 17842000 3094000 0.350 1082900"
224
  ]
225
  },
226
+ "execution_count": 14,
227
  "metadata": {},
228
  "output_type": "execute_result"
229
  }
 
232
  "get_table(10000000)"
233
  ]
234
  },
235
+ {
236
+ "cell_type": "code",
237
+ "execution_count": 41,
238
+ "metadata": {},
239
+ "outputs": [],
240
+ "source": [
241
+ "salarios = [450_000, 1000_000, 1_500_000, 2_000_000, 3_000_000, 5_000_000, 8_000_000, 10_000_000, 15_000_000]"
242
+ ]
243
+ },
244
+ {
245
+ "cell_type": "code",
246
+ "execution_count": 42,
247
+ "metadata": {},
248
+ "outputs": [],
249
+ "source": [
250
+ "df = pd.DataFrame(columns=[\"actual\", \"reforma\"], index=salarios)"
251
+ ]
252
+ },
253
+ {
254
+ "cell_type": "code",
255
+ "execution_count": 43,
256
+ "metadata": {},
257
+ "outputs": [],
258
+ "source": [
259
+ "df[\"actual\"] = [sum(descomponer_en_tramos(s, TRAMOS)[1]) for s in salarios]\n",
260
+ "df[\"reforma\"] = [sum(descomponer_en_tramos(s, TRAMOS_REFORMA)[1]) for s in salarios]"
261
+ ]
262
+ },
263
+ {
264
+ "cell_type": "code",
265
+ "execution_count": 44,
266
+ "metadata": {},
267
+ "outputs": [
268
+ {
269
+ "data": {
270
+ "text/html": [
271
+ "<div>\n",
272
+ "<style scoped>\n",
273
+ " .dataframe tbody tr th:only-of-type {\n",
274
+ " vertical-align: middle;\n",
275
+ " }\n",
276
+ "\n",
277
+ " .dataframe tbody tr th {\n",
278
+ " vertical-align: top;\n",
279
+ " }\n",
280
+ "\n",
281
+ " .dataframe thead th {\n",
282
+ " text-align: right;\n",
283
+ " }\n",
284
+ "</style>\n",
285
+ "<table border=\"1\" class=\"dataframe\">\n",
286
+ " <thead>\n",
287
+ " <tr style=\"text-align: right;\">\n",
288
+ " <th></th>\n",
289
+ " <th>actual</th>\n",
290
+ " <th>reforma</th>\n",
291
+ " </tr>\n",
292
+ " </thead>\n",
293
+ " <tbody>\n",
294
+ " <tr>\n",
295
+ " <th>450000</th>\n",
296
+ " <td>0</td>\n",
297
+ " <td>0</td>\n",
298
+ " </tr>\n",
299
+ " <tr>\n",
300
+ " <th>1000000</th>\n",
301
+ " <td>8920</td>\n",
302
+ " <td>8920</td>\n",
303
+ " </tr>\n",
304
+ " <tr>\n",
305
+ " <th>1500000</th>\n",
306
+ " <td>28920</td>\n",
307
+ " <td>28920</td>\n",
308
+ " </tr>\n",
309
+ " <tr>\n",
310
+ " <th>2000000</th>\n",
311
+ " <td>59840</td>\n",
312
+ " <td>59840</td>\n",
313
+ " </tr>\n",
314
+ " <tr>\n",
315
+ " <th>3000000</th>\n",
316
+ " <td>146550</td>\n",
317
+ " <td>146550</td>\n",
318
+ " </tr>\n",
319
+ " <tr>\n",
320
+ " <th>5000000</th>\n",
321
+ " <td>508795</td>\n",
322
+ " <td>537800</td>\n",
323
+ " </tr>\n",
324
+ " <tr>\n",
325
+ " <th>8000000</th>\n",
326
+ " <td>1457799</td>\n",
327
+ " <td>1649441</td>\n",
328
+ " </tr>\n",
329
+ " <tr>\n",
330
+ " <th>10000000</th>\n",
331
+ " <td>2157799</td>\n",
332
+ " <td>2507731</td>\n",
333
+ " </tr>\n",
334
+ " <tr>\n",
335
+ " <th>15000000</th>\n",
336
+ " <td>3907799</td>\n",
337
+ " <td>4657731</td>\n",
338
+ " </tr>\n",
339
+ " </tbody>\n",
340
+ "</table>\n",
341
+ "</div>"
342
+ ],
343
+ "text/plain": [
344
+ " actual reforma\n",
345
+ "450000 0 0\n",
346
+ "1000000 8920 8920\n",
347
+ "1500000 28920 28920\n",
348
+ "2000000 59840 59840\n",
349
+ "3000000 146550 146550\n",
350
+ "5000000 508795 537800\n",
351
+ "8000000 1457799 1649441\n",
352
+ "10000000 2157799 2507731\n",
353
+ "15000000 3907799 4657731"
354
+ ]
355
+ },
356
+ "execution_count": 44,
357
+ "metadata": {},
358
+ "output_type": "execute_result"
359
+ }
360
+ ],
361
+ "source": [
362
+ "df"
363
+ ]
364
+ },
365
+ {
366
+ "cell_type": "code",
367
+ "execution_count": 45,
368
+ "metadata": {},
369
+ "outputs": [],
370
+ "source": [
371
+ "import plotly.express as px"
372
+ ]
373
+ },
374
+ {
375
+ "cell_type": "code",
376
+ "execution_count": 46,
377
+ "metadata": {},
378
+ "outputs": [
379
+ {
380
+ "data": {
381
+ "application/vnd.plotly.v1+json": {
382
+ "config": {
383
+ "plotlyServerURL": "https://plot.ly"
384
+ },
385
+ "data": [
386
+ {
387
+ "hovertemplate": "variable=actual<br>index=%{x}<br>value=%{y}<extra></extra>",
388
+ "legendgroup": "actual",
389
+ "line": {
390
+ "color": "#636efa",
391
+ "dash": "solid"
392
+ },
393
+ "marker": {
394
+ "symbol": "circle"
395
+ },
396
+ "mode": "lines",
397
+ "name": "actual",
398
+ "orientation": "v",
399
+ "showlegend": true,
400
+ "type": "scatter",
401
+ "x": [
402
+ 450000,
403
+ 1000000,
404
+ 1500000,
405
+ 2000000,
406
+ 3000000,
407
+ 5000000,
408
+ 8000000,
409
+ 10000000,
410
+ 15000000
411
+ ],
412
+ "xaxis": "x",
413
+ "y": [
414
+ 0,
415
+ 8920,
416
+ 28920,
417
+ 59840,
418
+ 146550,
419
+ 508795,
420
+ 1457799,
421
+ 2157799,
422
+ 3907799
423
+ ],
424
+ "yaxis": "y"
425
+ },
426
+ {
427
+ "hovertemplate": "variable=reforma<br>index=%{x}<br>value=%{y}<extra></extra>",
428
+ "legendgroup": "reforma",
429
+ "line": {
430
+ "color": "#EF553B",
431
+ "dash": "solid"
432
+ },
433
+ "marker": {
434
+ "symbol": "circle"
435
+ },
436
+ "mode": "lines",
437
+ "name": "reforma",
438
+ "orientation": "v",
439
+ "showlegend": true,
440
+ "type": "scatter",
441
+ "x": [
442
+ 450000,
443
+ 1000000,
444
+ 1500000,
445
+ 2000000,
446
+ 3000000,
447
+ 5000000,
448
+ 8000000,
449
+ 10000000,
450
+ 15000000
451
+ ],
452
+ "xaxis": "x",
453
+ "y": [
454
+ 0,
455
+ 8920,
456
+ 28920,
457
+ 59840,
458
+ 146550,
459
+ 537800,
460
+ 1649441,
461
+ 2507731,
462
+ 4657731
463
+ ],
464
+ "yaxis": "y"
465
+ }
466
+ ],
467
+ "layout": {
468
+ "legend": {
469
+ "title": {
470
+ "text": "variable"
471
+ },
472
+ "tracegroupgap": 0
473
+ },
474
+ "margin": {
475
+ "t": 60
476
+ },
477
+ "template": {
478
+ "data": {
479
+ "bar": [
480
+ {
481
+ "error_x": {
482
+ "color": "#2a3f5f"
483
+ },
484
+ "error_y": {
485
+ "color": "#2a3f5f"
486
+ },
487
+ "marker": {
488
+ "line": {
489
+ "color": "#E5ECF6",
490
+ "width": 0.5
491
+ },
492
+ "pattern": {
493
+ "fillmode": "overlay",
494
+ "size": 10,
495
+ "solidity": 0.2
496
+ }
497
+ },
498
+ "type": "bar"
499
+ }
500
+ ],
501
+ "barpolar": [
502
+ {
503
+ "marker": {
504
+ "line": {
505
+ "color": "#E5ECF6",
506
+ "width": 0.5
507
+ },
508
+ "pattern": {
509
+ "fillmode": "overlay",
510
+ "size": 10,
511
+ "solidity": 0.2
512
+ }
513
+ },
514
+ "type": "barpolar"
515
+ }
516
+ ],
517
+ "carpet": [
518
+ {
519
+ "aaxis": {
520
+ "endlinecolor": "#2a3f5f",
521
+ "gridcolor": "white",
522
+ "linecolor": "white",
523
+ "minorgridcolor": "white",
524
+ "startlinecolor": "#2a3f5f"
525
+ },
526
+ "baxis": {
527
+ "endlinecolor": "#2a3f5f",
528
+ "gridcolor": "white",
529
+ "linecolor": "white",
530
+ "minorgridcolor": "white",
531
+ "startlinecolor": "#2a3f5f"
532
+ },
533
+ "type": "carpet"
534
+ }
535
+ ],
536
+ "choropleth": [
537
+ {
538
+ "colorbar": {
539
+ "outlinewidth": 0,
540
+ "ticks": ""
541
+ },
542
+ "type": "choropleth"
543
+ }
544
+ ],
545
+ "contour": [
546
+ {
547
+ "colorbar": {
548
+ "outlinewidth": 0,
549
+ "ticks": ""
550
+ },
551
+ "colorscale": [
552
+ [
553
+ 0,
554
+ "#0d0887"
555
+ ],
556
+ [
557
+ 0.1111111111111111,
558
+ "#46039f"
559
+ ],
560
+ [
561
+ 0.2222222222222222,
562
+ "#7201a8"
563
+ ],
564
+ [
565
+ 0.3333333333333333,
566
+ "#9c179e"
567
+ ],
568
+ [
569
+ 0.4444444444444444,
570
+ "#bd3786"
571
+ ],
572
+ [
573
+ 0.5555555555555556,
574
+ "#d8576b"
575
+ ],
576
+ [
577
+ 0.6666666666666666,
578
+ "#ed7953"
579
+ ],
580
+ [
581
+ 0.7777777777777778,
582
+ "#fb9f3a"
583
+ ],
584
+ [
585
+ 0.8888888888888888,
586
+ "#fdca26"
587
+ ],
588
+ [
589
+ 1,
590
+ "#f0f921"
591
+ ]
592
+ ],
593
+ "type": "contour"
594
+ }
595
+ ],
596
+ "contourcarpet": [
597
+ {
598
+ "colorbar": {
599
+ "outlinewidth": 0,
600
+ "ticks": ""
601
+ },
602
+ "type": "contourcarpet"
603
+ }
604
+ ],
605
+ "heatmap": [
606
+ {
607
+ "colorbar": {
608
+ "outlinewidth": 0,
609
+ "ticks": ""
610
+ },
611
+ "colorscale": [
612
+ [
613
+ 0,
614
+ "#0d0887"
615
+ ],
616
+ [
617
+ 0.1111111111111111,
618
+ "#46039f"
619
+ ],
620
+ [
621
+ 0.2222222222222222,
622
+ "#7201a8"
623
+ ],
624
+ [
625
+ 0.3333333333333333,
626
+ "#9c179e"
627
+ ],
628
+ [
629
+ 0.4444444444444444,
630
+ "#bd3786"
631
+ ],
632
+ [
633
+ 0.5555555555555556,
634
+ "#d8576b"
635
+ ],
636
+ [
637
+ 0.6666666666666666,
638
+ "#ed7953"
639
+ ],
640
+ [
641
+ 0.7777777777777778,
642
+ "#fb9f3a"
643
+ ],
644
+ [
645
+ 0.8888888888888888,
646
+ "#fdca26"
647
+ ],
648
+ [
649
+ 1,
650
+ "#f0f921"
651
+ ]
652
+ ],
653
+ "type": "heatmap"
654
+ }
655
+ ],
656
+ "heatmapgl": [
657
+ {
658
+ "colorbar": {
659
+ "outlinewidth": 0,
660
+ "ticks": ""
661
+ },
662
+ "colorscale": [
663
+ [
664
+ 0,
665
+ "#0d0887"
666
+ ],
667
+ [
668
+ 0.1111111111111111,
669
+ "#46039f"
670
+ ],
671
+ [
672
+ 0.2222222222222222,
673
+ "#7201a8"
674
+ ],
675
+ [
676
+ 0.3333333333333333,
677
+ "#9c179e"
678
+ ],
679
+ [
680
+ 0.4444444444444444,
681
+ "#bd3786"
682
+ ],
683
+ [
684
+ 0.5555555555555556,
685
+ "#d8576b"
686
+ ],
687
+ [
688
+ 0.6666666666666666,
689
+ "#ed7953"
690
+ ],
691
+ [
692
+ 0.7777777777777778,
693
+ "#fb9f3a"
694
+ ],
695
+ [
696
+ 0.8888888888888888,
697
+ "#fdca26"
698
+ ],
699
+ [
700
+ 1,
701
+ "#f0f921"
702
+ ]
703
+ ],
704
+ "type": "heatmapgl"
705
+ }
706
+ ],
707
+ "histogram": [
708
+ {
709
+ "marker": {
710
+ "pattern": {
711
+ "fillmode": "overlay",
712
+ "size": 10,
713
+ "solidity": 0.2
714
+ }
715
+ },
716
+ "type": "histogram"
717
+ }
718
+ ],
719
+ "histogram2d": [
720
+ {
721
+ "colorbar": {
722
+ "outlinewidth": 0,
723
+ "ticks": ""
724
+ },
725
+ "colorscale": [
726
+ [
727
+ 0,
728
+ "#0d0887"
729
+ ],
730
+ [
731
+ 0.1111111111111111,
732
+ "#46039f"
733
+ ],
734
+ [
735
+ 0.2222222222222222,
736
+ "#7201a8"
737
+ ],
738
+ [
739
+ 0.3333333333333333,
740
+ "#9c179e"
741
+ ],
742
+ [
743
+ 0.4444444444444444,
744
+ "#bd3786"
745
+ ],
746
+ [
747
+ 0.5555555555555556,
748
+ "#d8576b"
749
+ ],
750
+ [
751
+ 0.6666666666666666,
752
+ "#ed7953"
753
+ ],
754
+ [
755
+ 0.7777777777777778,
756
+ "#fb9f3a"
757
+ ],
758
+ [
759
+ 0.8888888888888888,
760
+ "#fdca26"
761
+ ],
762
+ [
763
+ 1,
764
+ "#f0f921"
765
+ ]
766
+ ],
767
+ "type": "histogram2d"
768
+ }
769
+ ],
770
+ "histogram2dcontour": [
771
+ {
772
+ "colorbar": {
773
+ "outlinewidth": 0,
774
+ "ticks": ""
775
+ },
776
+ "colorscale": [
777
+ [
778
+ 0,
779
+ "#0d0887"
780
+ ],
781
+ [
782
+ 0.1111111111111111,
783
+ "#46039f"
784
+ ],
785
+ [
786
+ 0.2222222222222222,
787
+ "#7201a8"
788
+ ],
789
+ [
790
+ 0.3333333333333333,
791
+ "#9c179e"
792
+ ],
793
+ [
794
+ 0.4444444444444444,
795
+ "#bd3786"
796
+ ],
797
+ [
798
+ 0.5555555555555556,
799
+ "#d8576b"
800
+ ],
801
+ [
802
+ 0.6666666666666666,
803
+ "#ed7953"
804
+ ],
805
+ [
806
+ 0.7777777777777778,
807
+ "#fb9f3a"
808
+ ],
809
+ [
810
+ 0.8888888888888888,
811
+ "#fdca26"
812
+ ],
813
+ [
814
+ 1,
815
+ "#f0f921"
816
+ ]
817
+ ],
818
+ "type": "histogram2dcontour"
819
+ }
820
+ ],
821
+ "mesh3d": [
822
+ {
823
+ "colorbar": {
824
+ "outlinewidth": 0,
825
+ "ticks": ""
826
+ },
827
+ "type": "mesh3d"
828
+ }
829
+ ],
830
+ "parcoords": [
831
+ {
832
+ "line": {
833
+ "colorbar": {
834
+ "outlinewidth": 0,
835
+ "ticks": ""
836
+ }
837
+ },
838
+ "type": "parcoords"
839
+ }
840
+ ],
841
+ "pie": [
842
+ {
843
+ "automargin": true,
844
+ "type": "pie"
845
+ }
846
+ ],
847
+ "scatter": [
848
+ {
849
+ "fillpattern": {
850
+ "fillmode": "overlay",
851
+ "size": 10,
852
+ "solidity": 0.2
853
+ },
854
+ "type": "scatter"
855
+ }
856
+ ],
857
+ "scatter3d": [
858
+ {
859
+ "line": {
860
+ "colorbar": {
861
+ "outlinewidth": 0,
862
+ "ticks": ""
863
+ }
864
+ },
865
+ "marker": {
866
+ "colorbar": {
867
+ "outlinewidth": 0,
868
+ "ticks": ""
869
+ }
870
+ },
871
+ "type": "scatter3d"
872
+ }
873
+ ],
874
+ "scattercarpet": [
875
+ {
876
+ "marker": {
877
+ "colorbar": {
878
+ "outlinewidth": 0,
879
+ "ticks": ""
880
+ }
881
+ },
882
+ "type": "scattercarpet"
883
+ }
884
+ ],
885
+ "scattergeo": [
886
+ {
887
+ "marker": {
888
+ "colorbar": {
889
+ "outlinewidth": 0,
890
+ "ticks": ""
891
+ }
892
+ },
893
+ "type": "scattergeo"
894
+ }
895
+ ],
896
+ "scattergl": [
897
+ {
898
+ "marker": {
899
+ "colorbar": {
900
+ "outlinewidth": 0,
901
+ "ticks": ""
902
+ }
903
+ },
904
+ "type": "scattergl"
905
+ }
906
+ ],
907
+ "scattermapbox": [
908
+ {
909
+ "marker": {
910
+ "colorbar": {
911
+ "outlinewidth": 0,
912
+ "ticks": ""
913
+ }
914
+ },
915
+ "type": "scattermapbox"
916
+ }
917
+ ],
918
+ "scatterpolar": [
919
+ {
920
+ "marker": {
921
+ "colorbar": {
922
+ "outlinewidth": 0,
923
+ "ticks": ""
924
+ }
925
+ },
926
+ "type": "scatterpolar"
927
+ }
928
+ ],
929
+ "scatterpolargl": [
930
+ {
931
+ "marker": {
932
+ "colorbar": {
933
+ "outlinewidth": 0,
934
+ "ticks": ""
935
+ }
936
+ },
937
+ "type": "scatterpolargl"
938
+ }
939
+ ],
940
+ "scatterternary": [
941
+ {
942
+ "marker": {
943
+ "colorbar": {
944
+ "outlinewidth": 0,
945
+ "ticks": ""
946
+ }
947
+ },
948
+ "type": "scatterternary"
949
+ }
950
+ ],
951
+ "surface": [
952
+ {
953
+ "colorbar": {
954
+ "outlinewidth": 0,
955
+ "ticks": ""
956
+ },
957
+ "colorscale": [
958
+ [
959
+ 0,
960
+ "#0d0887"
961
+ ],
962
+ [
963
+ 0.1111111111111111,
964
+ "#46039f"
965
+ ],
966
+ [
967
+ 0.2222222222222222,
968
+ "#7201a8"
969
+ ],
970
+ [
971
+ 0.3333333333333333,
972
+ "#9c179e"
973
+ ],
974
+ [
975
+ 0.4444444444444444,
976
+ "#bd3786"
977
+ ],
978
+ [
979
+ 0.5555555555555556,
980
+ "#d8576b"
981
+ ],
982
+ [
983
+ 0.6666666666666666,
984
+ "#ed7953"
985
+ ],
986
+ [
987
+ 0.7777777777777778,
988
+ "#fb9f3a"
989
+ ],
990
+ [
991
+ 0.8888888888888888,
992
+ "#fdca26"
993
+ ],
994
+ [
995
+ 1,
996
+ "#f0f921"
997
+ ]
998
+ ],
999
+ "type": "surface"
1000
+ }
1001
+ ],
1002
+ "table": [
1003
+ {
1004
+ "cells": {
1005
+ "fill": {
1006
+ "color": "#EBF0F8"
1007
+ },
1008
+ "line": {
1009
+ "color": "white"
1010
+ }
1011
+ },
1012
+ "header": {
1013
+ "fill": {
1014
+ "color": "#C8D4E3"
1015
+ },
1016
+ "line": {
1017
+ "color": "white"
1018
+ }
1019
+ },
1020
+ "type": "table"
1021
+ }
1022
+ ]
1023
+ },
1024
+ "layout": {
1025
+ "annotationdefaults": {
1026
+ "arrowcolor": "#2a3f5f",
1027
+ "arrowhead": 0,
1028
+ "arrowwidth": 1
1029
+ },
1030
+ "autotypenumbers": "strict",
1031
+ "coloraxis": {
1032
+ "colorbar": {
1033
+ "outlinewidth": 0,
1034
+ "ticks": ""
1035
+ }
1036
+ },
1037
+ "colorscale": {
1038
+ "diverging": [
1039
+ [
1040
+ 0,
1041
+ "#8e0152"
1042
+ ],
1043
+ [
1044
+ 0.1,
1045
+ "#c51b7d"
1046
+ ],
1047
+ [
1048
+ 0.2,
1049
+ "#de77ae"
1050
+ ],
1051
+ [
1052
+ 0.3,
1053
+ "#f1b6da"
1054
+ ],
1055
+ [
1056
+ 0.4,
1057
+ "#fde0ef"
1058
+ ],
1059
+ [
1060
+ 0.5,
1061
+ "#f7f7f7"
1062
+ ],
1063
+ [
1064
+ 0.6,
1065
+ "#e6f5d0"
1066
+ ],
1067
+ [
1068
+ 0.7,
1069
+ "#b8e186"
1070
+ ],
1071
+ [
1072
+ 0.8,
1073
+ "#7fbc41"
1074
+ ],
1075
+ [
1076
+ 0.9,
1077
+ "#4d9221"
1078
+ ],
1079
+ [
1080
+ 1,
1081
+ "#276419"
1082
+ ]
1083
+ ],
1084
+ "sequential": [
1085
+ [
1086
+ 0,
1087
+ "#0d0887"
1088
+ ],
1089
+ [
1090
+ 0.1111111111111111,
1091
+ "#46039f"
1092
+ ],
1093
+ [
1094
+ 0.2222222222222222,
1095
+ "#7201a8"
1096
+ ],
1097
+ [
1098
+ 0.3333333333333333,
1099
+ "#9c179e"
1100
+ ],
1101
+ [
1102
+ 0.4444444444444444,
1103
+ "#bd3786"
1104
+ ],
1105
+ [
1106
+ 0.5555555555555556,
1107
+ "#d8576b"
1108
+ ],
1109
+ [
1110
+ 0.6666666666666666,
1111
+ "#ed7953"
1112
+ ],
1113
+ [
1114
+ 0.7777777777777778,
1115
+ "#fb9f3a"
1116
+ ],
1117
+ [
1118
+ 0.8888888888888888,
1119
+ "#fdca26"
1120
+ ],
1121
+ [
1122
+ 1,
1123
+ "#f0f921"
1124
+ ]
1125
+ ],
1126
+ "sequentialminus": [
1127
+ [
1128
+ 0,
1129
+ "#0d0887"
1130
+ ],
1131
+ [
1132
+ 0.1111111111111111,
1133
+ "#46039f"
1134
+ ],
1135
+ [
1136
+ 0.2222222222222222,
1137
+ "#7201a8"
1138
+ ],
1139
+ [
1140
+ 0.3333333333333333,
1141
+ "#9c179e"
1142
+ ],
1143
+ [
1144
+ 0.4444444444444444,
1145
+ "#bd3786"
1146
+ ],
1147
+ [
1148
+ 0.5555555555555556,
1149
+ "#d8576b"
1150
+ ],
1151
+ [
1152
+ 0.6666666666666666,
1153
+ "#ed7953"
1154
+ ],
1155
+ [
1156
+ 0.7777777777777778,
1157
+ "#fb9f3a"
1158
+ ],
1159
+ [
1160
+ 0.8888888888888888,
1161
+ "#fdca26"
1162
+ ],
1163
+ [
1164
+ 1,
1165
+ "#f0f921"
1166
+ ]
1167
+ ]
1168
+ },
1169
+ "colorway": [
1170
+ "#636efa",
1171
+ "#EF553B",
1172
+ "#00cc96",
1173
+ "#ab63fa",
1174
+ "#FFA15A",
1175
+ "#19d3f3",
1176
+ "#FF6692",
1177
+ "#B6E880",
1178
+ "#FF97FF",
1179
+ "#FECB52"
1180
+ ],
1181
+ "font": {
1182
+ "color": "#2a3f5f"
1183
+ },
1184
+ "geo": {
1185
+ "bgcolor": "white",
1186
+ "lakecolor": "white",
1187
+ "landcolor": "#E5ECF6",
1188
+ "showlakes": true,
1189
+ "showland": true,
1190
+ "subunitcolor": "white"
1191
+ },
1192
+ "hoverlabel": {
1193
+ "align": "left"
1194
+ },
1195
+ "hovermode": "closest",
1196
+ "mapbox": {
1197
+ "style": "light"
1198
+ },
1199
+ "paper_bgcolor": "white",
1200
+ "plot_bgcolor": "#E5ECF6",
1201
+ "polar": {
1202
+ "angularaxis": {
1203
+ "gridcolor": "white",
1204
+ "linecolor": "white",
1205
+ "ticks": ""
1206
+ },
1207
+ "bgcolor": "#E5ECF6",
1208
+ "radialaxis": {
1209
+ "gridcolor": "white",
1210
+ "linecolor": "white",
1211
+ "ticks": ""
1212
+ }
1213
+ },
1214
+ "scene": {
1215
+ "xaxis": {
1216
+ "backgroundcolor": "#E5ECF6",
1217
+ "gridcolor": "white",
1218
+ "gridwidth": 2,
1219
+ "linecolor": "white",
1220
+ "showbackground": true,
1221
+ "ticks": "",
1222
+ "zerolinecolor": "white"
1223
+ },
1224
+ "yaxis": {
1225
+ "backgroundcolor": "#E5ECF6",
1226
+ "gridcolor": "white",
1227
+ "gridwidth": 2,
1228
+ "linecolor": "white",
1229
+ "showbackground": true,
1230
+ "ticks": "",
1231
+ "zerolinecolor": "white"
1232
+ },
1233
+ "zaxis": {
1234
+ "backgroundcolor": "#E5ECF6",
1235
+ "gridcolor": "white",
1236
+ "gridwidth": 2,
1237
+ "linecolor": "white",
1238
+ "showbackground": true,
1239
+ "ticks": "",
1240
+ "zerolinecolor": "white"
1241
+ }
1242
+ },
1243
+ "shapedefaults": {
1244
+ "line": {
1245
+ "color": "#2a3f5f"
1246
+ }
1247
+ },
1248
+ "ternary": {
1249
+ "aaxis": {
1250
+ "gridcolor": "white",
1251
+ "linecolor": "white",
1252
+ "ticks": ""
1253
+ },
1254
+ "baxis": {
1255
+ "gridcolor": "white",
1256
+ "linecolor": "white",
1257
+ "ticks": ""
1258
+ },
1259
+ "bgcolor": "#E5ECF6",
1260
+ "caxis": {
1261
+ "gridcolor": "white",
1262
+ "linecolor": "white",
1263
+ "ticks": ""
1264
+ }
1265
+ },
1266
+ "title": {
1267
+ "x": 0.05
1268
+ },
1269
+ "xaxis": {
1270
+ "automargin": true,
1271
+ "gridcolor": "white",
1272
+ "linecolor": "white",
1273
+ "ticks": "",
1274
+ "title": {
1275
+ "standoff": 15
1276
+ },
1277
+ "zerolinecolor": "white",
1278
+ "zerolinewidth": 2
1279
+ },
1280
+ "yaxis": {
1281
+ "automargin": true,
1282
+ "gridcolor": "white",
1283
+ "linecolor": "white",
1284
+ "ticks": "",
1285
+ "title": {
1286
+ "standoff": 15
1287
+ },
1288
+ "zerolinecolor": "white",
1289
+ "zerolinewidth": 2
1290
+ }
1291
+ }
1292
+ },
1293
+ "xaxis": {
1294
+ "anchor": "y",
1295
+ "domain": [
1296
+ 0,
1297
+ 1
1298
+ ],
1299
+ "title": {
1300
+ "text": "index"
1301
+ }
1302
+ },
1303
+ "yaxis": {
1304
+ "anchor": "x",
1305
+ "domain": [
1306
+ 0,
1307
+ 1
1308
+ ],
1309
+ "title": {
1310
+ "text": "value"
1311
+ }
1312
+ }
1313
+ }
1314
+ }
1315
+ },
1316
+ "metadata": {},
1317
+ "output_type": "display_data"
1318
+ }
1319
+ ],
1320
+ "source": [
1321
+ "px.line(df)"
1322
+ ]
1323
+ },
1324
  {
1325
  "cell_type": "code",
1326
  "execution_count": null,
impuestos.py CHANGED
@@ -1,4 +1,5 @@
1
  import pandas as pd
 
2
 
3
  # Valores de Junio 2022
4
  TRAMOS = {
@@ -59,3 +60,14 @@ def get_table(sueldo_bruto, tramos=TRAMOS):
59
  columns=["Desde", "Hasta", "Tasa", "Monto sujeto a impuesto", "Impuesto"],
60
  )
61
  return df
 
 
 
 
 
 
 
 
 
 
 
 
1
  import pandas as pd
2
+ import plotly.express as px
3
 
4
  # Valores de Junio 2022
5
  TRAMOS = {
 
60
  columns=["Desde", "Hasta", "Tasa", "Monto sujeto a impuesto", "Impuesto"],
61
  )
62
  return df
63
+
64
+
65
+ salarios = [450_000, 1000_000, 1_500_000, 2_000_000, 3_000_000, 5_000_000, 8_000_000, 10_000_000, 15_000_000]
66
+
67
+ def get_curve(descuentos):
68
+ def beneficios(s):
69
+ return max(s - descuentos, 0)
70
+ DF_CURVA = pd.DataFrame(columns=["actual", "reforma"], index=salarios)
71
+ DF_CURVA["actual"] = [sum(descomponer_en_tramos(s, TRAMOS)[1]) for s in salarios]
72
+ DF_CURVA["reforma"] = [sum(descomponer_en_tramos(beneficios(s) , TRAMOS_REFORMA)[1]) for s in salarios]
73
+ return px.line(DF_CURVA)