|
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) |
|
|