File size: 2,945 Bytes
91ab912 1f9a4bd 91ab912 0600838 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
import streamlit as st
import pandas as pd
import plotly.graph_objects as go
PERCENTILES = {
0.05: 81069,
0.06: 100000,
0.07: 116412,
0.08: 130566,
0.09: 150000,
0.1: 157072,
0.11: 180783,
0.12: 198996,
0.13: 200000,
0.14: 202674,
0.15: 230835,
0.16: 248745,
0.17: 253342,
0.18: 273619,
0.19: 288544,
0.2: 298494,
0.21: 300000,
0.22: 301305,
0.23: 304011,
0.24: 318393,
0.25: 321378,
0.26: 328343,
0.27: 334412,
0.28: 337000,
0.29: 344546,
0.3: 348242,
0.31: 350000,
0.32: 353326,
0.33: 354679,
0.34: 368142,
0.35: 378092,
0.36: 382040,
0.37: 395214,
0.38: 397991,
0.39: 397991,
0.4: 400000,
0.41: 400000,
0.42: 403321,
0.43: 405348,
0.44: 410000,
0.45: 420548,
0.46: 435749,
0.47: 447740,
0.48: 450000,
0.49: 452000,
0.5: 457690,
0.51: 476284,
0.52: 486426,
0.53: 497489,
0.54: 497489,
0.55: 500000,
0.56: 500000,
0.57: 506685,
0.58: 506685,
0.59: 525000,
0.6: 547219,
0.61: 552985,
0.62: 570000,
0.63: 596987,
0.64: 596987,
0.65: 600000,
0.66: 605000,
0.67: 610000,
0.68: 641761,
0.69: 658690,
0.7: 690000,
0.71: 700000,
0.72: 703428,
0.73: 726677,
0.74: 750000,
0.75: 795983,
0.76: 800000,
0.77: 803480,
0.78: 820829,
0.79: 861364,
0.8: 895481,
0.81: 912032,
0.82: 972834,
0.83: 994978,
0.84: 1004351,
0.85: 1023503,
0.86: 1094476,
0.87: 1193974,
0.88: 1201000,
0.89: 1293471,
0.9: 1388316,
0.91: 1492468,
0.92: 1520000,
0.93: 1600000,
0.94: 1800000,
0.95: 1989957,
0.96: 2067273,
0.97: 2487446,
0.98: 2984935,
0.99: 3979914
}
st.header("Observatorio de sueldos en Chile")
sueldo = st.number_input(
"Ingrese su sueldo líquido mensual",
value = 500_000,
min_value = 100_000,
format = "%d",
)
DF_CURVA = pd.Series(PERCENTILES)
aux = DF_CURVA[DF_CURVA < sueldo]
if DF_CURVA.iloc[-1] <sueldo:
percentile_sueldo = 99
else:
percentile_sueldo = int(100*DF_CURVA[DF_CURVA>=sueldo].index[0])
st.write(percentile_sueldo, '% de las personas ocupadas ganan menos que usted.')
fig = go.Figure()
fig.add_trace(go.Scatter(x=list(DF_CURVA.index), y=list(DF_CURVA.values), hovertemplate='Sueldo mensual: %{y:$,.0f}<extra></extra>'))
fig.add_trace(go.Scatter(x=list(aux.index), y=list(aux.values), fill='tozeroy', hovertemplate='<extra></extra>'))
fig.update_layout(
title = f'{percentile_sueldo} % de las personas ocupadas ganan menos que usted.',
yaxis_title = 'Sueldos mensuales',
xaxis = dict(
tickmode = 'array',
tickvals = [.1*i for i in range(11)],
ticktext = [f'{10*i}%' for i in range(11)]
),
xaxis_tickformat=',.0%',
yaxis_tickformat=',.0'.replace(',',','),
yaxis = dict(
tickmode = 'array',
tickvals = [500_000*i for i in range(9)],
ticktext = [f'${500_000*i:,}'.replace(',','.') for i in range(9)]
),
showlegend=False
)
fig.update_layout(
hovermode="x",
hoverlabel=dict(
bgcolor="white",
)
)
st.plotly_chart(fig, use_container_width=True)
st.markdown("Crédito: [Alonso Silva](https://twitter.com/alonsosilva)")
|