Skip to content

Instantly share code, notes, and snippets.

@pedrogk
Created March 26, 2021 17:30
Show Gist options
  • Save pedrogk/14c3f67baf060a91f4e7bf2d0783a6ee to your computer and use it in GitHub Desktop.
Save pedrogk/14c3f67baf060a91f4e7bf2d0783a6ee to your computer and use it in GitHub Desktop.
Estudio Salarios SG.ipynb
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
},
"colab": {
"name": "Estudio Salarios SG.ipynb",
"provenance": [],
"include_colab_link": true
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/pedrogk/14c3f67baf060a91f4e7bf2d0783a6ee/estudio-salarios-sg.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "code",
"metadata": {
"id": "BAxpDBY61pYl"
},
"source": [
"import pandas as pd\n",
"import numpy as np\n",
"\n",
"# Bokeh es la biblioteca que usaremos para las gráficas\n",
"from bokeh.plotting import figure, show\n",
"from bokeh.io import output_notebook\n",
"from bokeh.models import ColumnDataSource, HoverTool, NumeralTickFormatter, DataTable, TableColumn, NumberFormatter\n",
"from bokeh.palettes import Dark2, YlGn9, Viridis, Pastel1\n",
"\n",
"# output_notebook() activa el despliegue de gráficas en un notebook.\n",
"output_notebook()"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "bRyj1gwg1pYr",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "e8dd4b78-d1f9-44f6-dafb-54fb10c0dd9a"
},
"source": [
"# Cargamos en un dataframe los datos de las respuestas, que están en un archivo en un repositorio de GitHub.\n",
"df = pd.read_csv(\"https://raw.githubusercontent.com/softwareguru/salarios-notebook/main/answers-2021.csv\", index_col=0)\n",
"# El salario de las personas de Mx se guarda en la columna salarymx y está en pesos.\n",
"# Para los siguientes análisis solo vamos a tomar en cuenta datos de personas en México así que filtramos el dataframe para solo incluir a estos.\n",
"df = df[(df['country'] == 'México')]\n",
"df.count()"
],
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"created 1516\n",
"salarymx 1516\n",
"salaryusd 1516\n",
"extramx 1516\n",
"extrausd 1516\n",
" ... \n",
"ben_vouchers 640\n",
"covid_remoto 1515\n",
"covid_salario 1515\n",
"covid_carga 1515\n",
"covid_apoyo 1027\n",
"Length: 161, dtype: int64"
]
},
"metadata": {
"tags": []
},
"execution_count": 3
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "0Qb7QO7mJs9T"
},
"source": [
"Como podemos ver, tenemos 1516 datos para México."
]
},
{
"cell_type": "code",
"metadata": {
"id": "nAKrIB661pYr",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "054ae684-eb81-46f9-9a89-63ec254b2278"
},
"source": [
"df.salarymx.describe()"
],
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"count 1516.000000\n",
"mean 47379.291557\n",
"std 34482.023448\n",
"min 0.000000\n",
"25% 24000.000000\n",
"50% 40000.000000\n",
"75% 60000.000000\n",
"max 250000.000000\n",
"Name: salarymx, dtype: float64"
]
},
"metadata": {
"tags": []
},
"execution_count": 4
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "DWZLcxwhKPyy"
},
"source": [
"El salario promedio (mean) es 47,379 y el salario medio (mediana) es 40,000. El 25% inferior gana un máximo de 24 mil pesos y el 25% superior gana 60 mil pesos o más. La desviación estándar es 34,482, que es un valor alto (72% de la media) lo cual confirma que difícilmente podemos tener una buena predicción sin agregar más variables/factores."
]
},
{
"cell_type": "code",
"metadata": {
"id": "5rOQQyRq1pYs",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "4dcf036b-4af8-4ba1-ad5a-ce697a4ce5eb"
},
"source": [
"df.experience.describe()"
],
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"count 1516.000000\n",
"mean 9.978232\n",
"std 7.573198\n",
"min 0.000000\n",
"25% 4.000000\n",
"50% 8.000000\n",
"75% 14.000000\n",
"max 40.000000\n",
"Name: experience, dtype: float64"
]
},
"metadata": {
"tags": []
},
"execution_count": 5
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "AcTFrBk41pYu"
},
"source": [
"## Experiencia\n",
"Vamos a ver cómo se comporta el salario dependiendo de la experiencia. \n",
"\n",
"Lo primero que haré es agrupar en clusters en base a los años de experiencia. Arbitrariamente he asignado los límites de cada grupo buscando tener grupos de tamaño similar."
]
},
{
"cell_type": "code",
"metadata": {
"id": "3MZK6OsA1pYu",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 284
},
"outputId": "aee699bb-7e27-49e7-946a-458e81b94b11"
},
"source": [
"# Agrupo los datos en base a su experiencia.\n",
"df['exp_bin'] = pd.cut(df['experience'],bins=[-0.1,2,4,6,8,10,14,20,40])\n",
"\n",
"exp = df.groupby('exp_bin')['salarymx'].agg(['count', 'median','mean', 'std'])\n",
"# Groupby deja exp_bin como un índice, lo necesitamos como una columna normal así que damos reset_index.\n",
"exp = exp.reset_index()\n",
"exp.head(10)"
],
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>exp_bin</th>\n",
" <th>count</th>\n",
" <th>median</th>\n",
" <th>mean</th>\n",
" <th>std</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>(-0.1, 2.0]</td>\n",
" <td>190</td>\n",
" <td>18000</td>\n",
" <td>19634.905263</td>\n",
" <td>12759.855713</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>(2.0, 4.0]</td>\n",
" <td>208</td>\n",
" <td>30000</td>\n",
" <td>32552.855769</td>\n",
" <td>19009.845680</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>(4.0, 6.0]</td>\n",
" <td>242</td>\n",
" <td>40000</td>\n",
" <td>46250.913223</td>\n",
" <td>31112.060680</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>(6.0, 8.0]</td>\n",
" <td>172</td>\n",
" <td>45500</td>\n",
" <td>50291.191860</td>\n",
" <td>30145.588397</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>(8.0, 10.0]</td>\n",
" <td>150</td>\n",
" <td>52500</td>\n",
" <td>59424.000000</td>\n",
" <td>41250.081440</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>(10.0, 14.0]</td>\n",
" <td>189</td>\n",
" <td>54000</td>\n",
" <td>57884.608466</td>\n",
" <td>33391.829340</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>(14.0, 20.0]</td>\n",
" <td>211</td>\n",
" <td>52000</td>\n",
" <td>56887.843602</td>\n",
" <td>35317.410225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>(20.0, 40.0]</td>\n",
" <td>154</td>\n",
" <td>50000</td>\n",
" <td>62502.909091</td>\n",
" <td>43637.080802</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" exp_bin count median mean std\n",
"0 (-0.1, 2.0] 190 18000 19634.905263 12759.855713\n",
"1 (2.0, 4.0] 208 30000 32552.855769 19009.845680\n",
"2 (4.0, 6.0] 242 40000 46250.913223 31112.060680\n",
"3 (6.0, 8.0] 172 45500 50291.191860 30145.588397\n",
"4 (8.0, 10.0] 150 52500 59424.000000 41250.081440\n",
"5 (10.0, 14.0] 189 54000 57884.608466 33391.829340\n",
"6 (14.0, 20.0] 211 52000 56887.843602 35317.410225\n",
"7 (20.0, 40.0] 154 50000 62502.909091 43637.080802"
]
},
"metadata": {
"tags": []
},
"execution_count": 75
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "-dEPCus_1pYu",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 417
},
"outputId": "d288bcbc-a4ad-4e2c-f524-a1d474609d58"
},
"source": [
"# Los valores en exp_bin son intervalos pero para la gráfica necesitamos que sean strings/categoricas.\n",
"exp_labels = ['0-2', '3-4', '5-6', '7-8', '9-10', '11-14', '15-20', '20+']\n",
"exp['exp_bin'] = exp_labels\n",
"\n",
"# Tomo la paleta YlGn9 que tiene 9 colores y uso los primeros 8. No uso YlGn8 porque el último tono es muy claro.\n",
"from bokeh.palettes import YlGn9\n",
"aux = YlGn9[0:8]\n",
"\n",
"# El orden de colores de esta paleta es de obscuro a claro. Lo invierto para ir de claro a obscuro.\n",
"exp['color'] = aux[::-1]\n",
"\n",
"src = ColumnDataSource(exp)\n",
"p = figure(x_range=exp_labels, plot_height=400, plot_width=700)\n",
"p.vbar(source=src, x='exp_bin', top='median', width=0.95, color='color')\n",
"p.title.text = 'Salario medio de acuerdo a a la experiencia'\n",
"p.xaxis.axis_label = 'Experiencia (años)'\n",
"p.yaxis.axis_label = 'Salario bruto mensual (MXN)'\n",
"p.yaxis.formatter = NumeralTickFormatter(format='$0 a')\n",
"\n",
"hover = HoverTool()\n",
"hover.tooltips=[\n",
" ('Experiencia', '@exp_bin años'),\n",
" ('Observaciones', '@count'),\n",
" ('Salario medio', '@median{$0,0}'),\n",
"]\n",
"p.add_tools(hover)\n",
"\n",
"show(p)"
],
"execution_count": null,
"outputs": [
{
"output_type": "display_data",
"data": {
"application/javascript": [
"\n",
"(function(root) {\n",
" function now() {\n",
" return new Date();\n",
" }\n",
"\n",
" var force = true;\n",
"\n",
" if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n",
" root._bokeh_onload_callbacks = [];\n",
" root._bokeh_is_loading = undefined;\n",
" }\n",
"\n",
" var JS_MIME_TYPE = 'application/javascript';\n",
" var HTML_MIME_TYPE = 'text/html';\n",
" var EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n",
" var CLASS_NAME = 'output_bokeh rendered_html';\n",
"\n",
" /**\n",
" * Render data to the DOM node\n",
" */\n",
" function render(props, node) {\n",
" var script = document.createElement(\"script\");\n",
" node.appendChild(script);\n",
" }\n",
"\n",
" /**\n",
" * Handle when an output is cleared or removed\n",
" */\n",
" function handleClearOutput(event, handle) {\n",
" var cell = handle.cell;\n",
"\n",
" var id = cell.output_area._bokeh_element_id;\n",
" var server_id = cell.output_area._bokeh_server_id;\n",
" // Clean up Bokeh references\n",
" if (id != null && id in Bokeh.index) {\n",
" Bokeh.index[id].model.document.clear();\n",
" delete Bokeh.index[id];\n",
" }\n",
"\n",
" if (server_id !== undefined) {\n",
" // Clean up Bokeh references\n",
" var cmd = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n",
" cell.notebook.kernel.execute(cmd, {\n",
" iopub: {\n",
" output: function(msg) {\n",
" var id = msg.content.text.trim();\n",
" if (id in Bokeh.index) {\n",
" Bokeh.index[id].model.document.clear();\n",
" delete Bokeh.index[id];\n",
" }\n",
" }\n",
" }\n",
" });\n",
" // Destroy server and session\n",
" var cmd = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n",
" cell.notebook.kernel.execute(cmd);\n",
" }\n",
" }\n",
"\n",
" /**\n",
" * Handle when a new output is added\n",
" */\n",
" function handleAddOutput(event, handle) {\n",
" var output_area = handle.output_area;\n",
" var output = handle.output;\n",
"\n",
" // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n",
" if ((output.output_type != \"display_data\") || (!output.data.hasOwnProperty(EXEC_MIME_TYPE))) {\n",
" return\n",
" }\n",
"\n",
" var toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n",
"\n",
" if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n",
" toinsert[toinsert.length - 1].firstChild.textContent = output.data[JS_MIME_TYPE];\n",
" // store reference to embed id on output_area\n",
" output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n",
" }\n",
" if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n",
" var bk_div = document.createElement(\"div\");\n",
" bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n",
" var script_attrs = bk_div.children[0].attributes;\n",
" for (var i = 0; i < script_attrs.length; i++) {\n",
" toinsert[toinsert.length - 1].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n",
" toinsert[toinsert.length - 1].firstChild.textContent = bk_div.children[0].textContent\n",
" }\n",
" // store reference to server id on output_area\n",
" output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n",
" }\n",
" }\n",
"\n",
" function register_renderer(events, OutputArea) {\n",
"\n",
" function append_mime(data, metadata, element) {\n",
" // create a DOM node to render to\n",
" var toinsert = this.create_output_subarea(\n",
" metadata,\n",
" CLASS_NAME,\n",
" EXEC_MIME_TYPE\n",
" );\n",
" this.keyboard_manager.register_events(toinsert);\n",
" // Render to node\n",
" var props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n",
" render(props, toinsert[toinsert.length - 1]);\n",
" element.append(toinsert);\n",
" return toinsert\n",
" }\n",
"\n",
" /* Handle when an output is cleared or removed */\n",
" events.on('clear_output.CodeCell', handleClearOutput);\n",
" events.on('delete.Cell', handleClearOutput);\n",
"\n",
" /* Handle when a new output is added */\n",
" events.on('output_added.OutputArea', handleAddOutput);\n",
"\n",
" /**\n",
" * Register the mime type and append_mime function with output_area\n",
" */\n",
" OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n",
" /* Is output safe? */\n",
" safe: true,\n",
" /* Index of renderer in `output_area.display_order` */\n",
" index: 0\n",
" });\n",
" }\n",
"\n",
" // register the mime type if in Jupyter Notebook environment and previously unregistered\n",
" if (root.Jupyter !== undefined) {\n",
" var events = require('base/js/events');\n",
" var OutputArea = require('notebook/js/outputarea').OutputArea;\n",
"\n",
" if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n",
" register_renderer(events, OutputArea);\n",
" }\n",
" }\n",
"\n",
" \n",
" if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n",
" root._bokeh_timeout = Date.now() + 5000;\n",
" root._bokeh_failed_load = false;\n",
" }\n",
"\n",
" var NB_LOAD_WARNING = {'data': {'text/html':\n",
" \"<div style='background-color: #fdd'>\\n\"+\n",
" \"<p>\\n\"+\n",
" \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n",
" \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n",
" \"</p>\\n\"+\n",
" \"<ul>\\n\"+\n",
" \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n",
" \"<li>use INLINE resources instead, as so:</li>\\n\"+\n",
" \"</ul>\\n\"+\n",
" \"<code>\\n\"+\n",
" \"from bokeh.resources import INLINE\\n\"+\n",
" \"output_notebook(resources=INLINE)\\n\"+\n",
" \"</code>\\n\"+\n",
" \"</div>\"}};\n",
"\n",
" function display_loaded() {\n",
" var el = document.getElementById(null);\n",
" if (el != null) {\n",
" el.textContent = \"BokehJS is loading...\";\n",
" }\n",
" if (root.Bokeh !== undefined) {\n",
" if (el != null) {\n",
" el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n",
" }\n",
" } else if (Date.now() < root._bokeh_timeout) {\n",
" setTimeout(display_loaded, 100)\n",
" }\n",
" }\n",
"\n",
"\n",
" function run_callbacks() {\n",
" try {\n",
" root._bokeh_onload_callbacks.forEach(function(callback) {\n",
" if (callback != null)\n",
" callback();\n",
" });\n",
" } finally {\n",
" delete root._bokeh_onload_callbacks\n",
" }\n",
" console.debug(\"Bokeh: all callbacks have finished\");\n",
" }\n",
"\n",
" function load_libs(css_urls, js_urls, callback) {\n",
" if (css_urls == null) css_urls = [];\n",
" if (js_urls == null) js_urls = [];\n",
"\n",
" root._bokeh_onload_callbacks.push(callback);\n",
" if (root._bokeh_is_loading > 0) {\n",
" console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n",
" return null;\n",
" }\n",
" if (js_urls == null || js_urls.length === 0) {\n",
" run_callbacks();\n",
" return null;\n",
" }\n",
" console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n",
" root._bokeh_is_loading = css_urls.length + js_urls.length;\n",
"\n",
" function on_load() {\n",
" root._bokeh_is_loading--;\n",
" if (root._bokeh_is_loading === 0) {\n",
" console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n",
" run_callbacks()\n",
" }\n",
" }\n",
"\n",
" function on_error() {\n",
" console.error(\"failed to load \" + url);\n",
" }\n",
"\n",
" for (var i = 0; i < css_urls.length; i++) {\n",
" var url = css_urls[i];\n",
" const element = document.createElement(\"link\");\n",
" element.onload = on_load;\n",
" element.onerror = on_error;\n",
" element.rel = \"stylesheet\";\n",
" element.type = \"text/css\";\n",
" element.href = url;\n",
" console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n",
" document.body.appendChild(element);\n",
" }\n",
"\n",
" const hashes = {\"https://cdn.bokeh.org/bokeh/release/bokeh-2.1.1.min.js\": \"kLr4fYcqcSpbuI95brIH3vnnYCquzzSxHPU6XGQCIkQRGJwhg0StNbj1eegrHs12\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.1.1.min.js\": \"xIGPmVtaOm+z0BqfSOMn4lOR6ciex448GIKG4eE61LsAvmGj48XcMQZtKcE/UXZe\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.1.1.min.js\": \"Dc9u1wF/0zApGIWoBbH77iWEHtdmkuYWG839Uzmv8y8yBLXebjO9ZnERsde5Ln/P\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.1.1.min.js\": \"cT9JaBz7GiRXdENrJLZNSC6eMNF3nh3fa5fTF51Svp+ukxPdwcU5kGXGPBgDCa2j\"};\n",
"\n",
" for (var i = 0; i < js_urls.length; i++) {\n",
" var url = js_urls[i];\n",
" var element = document.createElement('script');\n",
" element.onload = on_load;\n",
" element.onerror = on_error;\n",
" element.async = false;\n",
" element.src = url;\n",
" if (url in hashes) {\n",
" element.crossOrigin = \"anonymous\";\n",
" element.integrity = \"sha384-\" + hashes[url];\n",
" }\n",
" console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n",
" document.head.appendChild(element);\n",
" }\n",
" };\n",
"\n",
" function inject_raw_css(css) {\n",
" const element = document.createElement(\"style\");\n",
" element.appendChild(document.createTextNode(css));\n",
" document.body.appendChild(element);\n",
" }\n",
"\n",
" \n",
" var js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.1.1.min.js\"];\n",
" var css_urls = [];\n",
" \n",
"\n",
" var inline_js = [\n",
" function(Bokeh) {\n",
" Bokeh.set_log_level(\"info\");\n",
" },\n",
" function(Bokeh) {\n",
" \n",
" \n",
" }\n",
" ];\n",
"\n",
" function run_inline_js() {\n",
" \n",
" if (root.Bokeh !== undefined || force === true) {\n",
" \n",
" for (var i = 0; i < inline_js.length; i++) {\n",
" inline_js[i].call(root, root.Bokeh);\n",
" }\n",
" } else if (Date.now() < root._bokeh_timeout) {\n",
" setTimeout(run_inline_js, 100);\n",
" } else if (!root._bokeh_failed_load) {\n",
" console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n",
" root._bokeh_failed_load = true;\n",
" } else if (force !== true) {\n",
" var cell = $(document.getElementById(null)).parents('.cell').data().cell;\n",
" cell.output_area.append_execute_result(NB_LOAD_WARNING)\n",
" }\n",
"\n",
" }\n",
"\n",
" if (root._bokeh_is_loading === 0) {\n",
" console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n",
" run_inline_js();\n",
" } else {\n",
" load_libs(css_urls, js_urls, function() {\n",
" console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n",
" run_inline_js();\n",
" });\n",
" }\n",
"}(window));"
],
"application/vnd.bokehjs_load.v0+json": "\n(function(root) {\n function now() {\n return new Date();\n }\n\n var force = true;\n\n if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\n \n\n \n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n var NB_LOAD_WARNING = {'data': {'text/html':\n \"<div style='background-color: #fdd'>\\n\"+\n \"<p>\\n\"+\n \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n \"</p>\\n\"+\n \"<ul>\\n\"+\n \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n \"<li>use INLINE resources instead, as so:</li>\\n\"+\n \"</ul>\\n\"+\n \"<code>\\n\"+\n \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"</code>\\n\"+\n \"</div>\"}};\n\n function display_loaded() {\n var el = document.getElementById(null);\n if (el != null) {\n el.textContent = \"BokehJS is loading...\";\n }\n if (root.Bokeh !== undefined) {\n if (el != null) {\n el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(display_loaded, 100)\n }\n }\n\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) {\n if (callback != null)\n callback();\n });\n } finally {\n delete root._bokeh_onload_callbacks\n }\n console.debug(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(css_urls, js_urls, callback) {\n if (css_urls == null) css_urls = [];\n if (js_urls == null) js_urls = [];\n\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls == null || js_urls.length === 0) {\n run_callbacks();\n return null;\n }\n console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n root._bokeh_is_loading = css_urls.length + js_urls.length;\n\n function on_load() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n run_callbacks()\n }\n }\n\n function on_error() {\n console.error(\"failed to load \" + url);\n }\n\n for (var i = 0; i < css_urls.length; i++) {\n var url = css_urls[i];\n const element = document.createElement(\"link\");\n element.onload = on_load;\n element.onerror = on_error;\n element.rel = \"stylesheet\";\n element.type = \"text/css\";\n element.href = url;\n console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n document.body.appendChild(element);\n }\n\n const hashes = {\"https://cdn.bokeh.org/bokeh/release/bokeh-2.1.1.min.js\": \"kLr4fYcqcSpbuI95brIH3vnnYCquzzSxHPU6XGQCIkQRGJwhg0StNbj1eegrHs12\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.1.1.min.js\": \"xIGPmVtaOm+z0BqfSOMn4lOR6ciex448GIKG4eE61LsAvmGj48XcMQZtKcE/UXZe\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.1.1.min.js\": \"Dc9u1wF/0zApGIWoBbH77iWEHtdmkuYWG839Uzmv8y8yBLXebjO9ZnERsde5Ln/P\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.1.1.min.js\": \"cT9JaBz7GiRXdENrJLZNSC6eMNF3nh3fa5fTF51Svp+ukxPdwcU5kGXGPBgDCa2j\"};\n\n for (var i = 0; i < js_urls.length; i++) {\n var url = js_urls[i];\n var element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error;\n element.async = false;\n element.src = url;\n if (url in hashes) {\n element.crossOrigin = \"anonymous\";\n element.integrity = \"sha384-\" + hashes[url];\n }\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n };\n\n function inject_raw_css(css) {\n const element = document.createElement(\"style\");\n element.appendChild(document.createTextNode(css));\n document.body.appendChild(element);\n }\n\n \n var js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.1.1.min.js\"];\n var css_urls = [];\n \n\n var inline_js = [\n function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\n function(Bokeh) {\n \n \n }\n ];\n\n function run_inline_js() {\n \n if (root.Bokeh !== undefined || force === true) {\n \n for (var i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n } else if (force !== true) {\n var cell = $(document.getElementById(null)).parents('.cell').data().cell;\n cell.output_area.append_execute_result(NB_LOAD_WARNING)\n }\n\n }\n\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(css_urls, js_urls, function() {\n console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));"
},
"metadata": {
"tags": []
}
},
{
"output_type": "display_data",
"data": {
"text/html": [
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
" <div class=\"bk-root\" id=\"33e2a8ce-0beb-4ed8-9555-61437e5ce818\" data-root-id=\"2696\"></div>\n"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "display_data",
"data": {
"application/javascript": [
"(function(root) {\n",
" function embed_document(root) {\n",
" \n",
" var docs_json = {\"1a5e8f14-b2bf-4035-a334-165f6fb81ca7\":{\"roots\":{\"references\":[{\"attributes\":{\"below\":[{\"id\":\"2705\"}],\"center\":[{\"id\":\"2707\"},{\"id\":\"2711\"}],\"left\":[{\"id\":\"2708\"}],\"plot_height\":400,\"plot_width\":700,\"renderers\":[{\"id\":\"2729\"}],\"title\":{\"id\":\"2731\"},\"toolbar\":{\"id\":\"2719\"},\"x_range\":{\"id\":\"2697\"},\"x_scale\":{\"id\":\"2701\"},\"y_range\":{\"id\":\"2699\"},\"y_scale\":{\"id\":\"2703\"}},\"id\":\"2696\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{},\"id\":\"2703\",\"type\":\"LinearScale\"},{\"attributes\":{\"axis\":{\"id\":\"2705\"},\"ticker\":null},\"id\":\"2707\",\"type\":\"Grid\"},{\"attributes\":{\"factors\":[\"0-2\",\"3-4\",\"5-6\",\"7-8\",\"9-10\",\"11-14\",\"15-20\",\"20+\"]},\"id\":\"2697\",\"type\":\"FactorRange\"},{\"attributes\":{\"axis_label\":\"Salario bruto mensual (MXN)\",\"formatter\":{\"id\":\"2732\"},\"ticker\":{\"id\":\"2709\"}},\"id\":\"2708\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"2713\",\"type\":\"WheelZoomTool\"},{\"attributes\":{},\"id\":\"2699\",\"type\":\"DataRange1d\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":0.5,\"fill_color\":\"lightgrey\",\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":1.0,\"line_color\":\"black\",\"line_dash\":[4,4],\"line_width\":2,\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"2718\",\"type\":\"BoxAnnotation\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"field\":\"color\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"field\":\"color\"},\"top\":{\"field\":\"median\"},\"width\":{\"value\":0.95},\"x\":{\"field\":\"exp_bin\"}},\"id\":\"2728\",\"type\":\"VBar\"},{\"attributes\":{},\"id\":\"2832\",\"type\":\"Selection\"},{\"attributes\":{},\"id\":\"2701\",\"type\":\"CategoricalScale\"},{\"attributes\":{},\"id\":\"2833\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"callback\":null,\"tooltips\":[[\"Experiencia\",\"@exp_bin a\\u00f1os\"],[\"Observaciones\",\"@count\"],[\"Salario medio\",\"@median{$0,0}\"]]},\"id\":\"2734\",\"type\":\"HoverTool\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_multi\":null,\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"2712\"},{\"id\":\"2713\"},{\"id\":\"2714\"},{\"id\":\"2715\"},{\"id\":\"2716\"},{\"id\":\"2717\"},{\"id\":\"2734\"}]},\"id\":\"2719\",\"type\":\"Toolbar\"},{\"attributes\":{\"data\":{\"color\":[\"#f7fcb9\",\"#d9f0a3\",\"#addd8e\",\"#78c679\",\"#41ab5d\",\"#238443\",\"#006837\",\"#004529\"],\"count\":[190,208,242,172,150,189,211,154],\"exp_bin\":[\"0-2\",\"3-4\",\"5-6\",\"7-8\",\"9-10\",\"11-14\",\"15-20\",\"20+\"],\"index\":[0,1,2,3,4,5,6,7],\"mean\":{\"__ndarray__\":\"XOLU77ks00DFTuzENsrfQEy8HzldleZA4o64I2aO6EAAAAAAAATtQCPejHiTQ+xAIWfJ/vrG60B00UUX3YTuQA==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[8]},\"median\":[18000,30000,40000,45500,52500,54000,52000,50000],\"std\":{\"__ndarray__\":\"65YCiO3ryEDNZ58fdpDSQCYKMOIDYt5AAYZKqGVw3UCBryebQiTkQCx/84n6TeBAyEePIK0+4UBqEO6Vok7lQA==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[8]}},\"selected\":{\"id\":\"2832\"},\"selection_policy\":{\"id\":\"2833\"}},\"id\":\"2695\",\"type\":\"ColumnDataSource\"},{\"attributes\":{},\"id\":\"2829\",\"type\":\"CategoricalTickFormatter\"},{\"attributes\":{\"text\":\"Salario medio de acuerdo a a la experiencia\"},\"id\":\"2731\",\"type\":\"Title\"},{\"attributes\":{},\"id\":\"2717\",\"type\":\"HelpTool\"},{\"attributes\":{},\"id\":\"2716\",\"type\":\"ResetTool\"},{\"attributes\":{\"fill_color\":{\"field\":\"color\"},\"line_color\":{\"field\":\"color\"},\"top\":{\"field\":\"median\"},\"width\":{\"value\":0.95},\"x\":{\"field\":\"exp_bin\"}},\"id\":\"2727\",\"type\":\"VBar\"},{\"attributes\":{},\"id\":\"2709\",\"type\":\"BasicTicker\"},{\"attributes\":{\"axis\":{\"id\":\"2708\"},\"dimension\":1,\"ticker\":null},\"id\":\"2711\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"2715\",\"type\":\"SaveTool\"},{\"attributes\":{\"axis_label\":\"Experiencia (a\\u00f1os)\",\"formatter\":{\"id\":\"2829\"},\"ticker\":{\"id\":\"2706\"}},\"id\":\"2705\",\"type\":\"CategoricalAxis\"},{\"attributes\":{\"format\":\"$0 a\"},\"id\":\"2732\",\"type\":\"NumeralTickFormatter\"},{\"attributes\":{\"overlay\":{\"id\":\"2718\"}},\"id\":\"2714\",\"type\":\"BoxZoomTool\"},{\"attributes\":{},\"id\":\"2706\",\"type\":\"CategoricalTicker\"},{\"attributes\":{\"source\":{\"id\":\"2695\"}},\"id\":\"2730\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"2712\",\"type\":\"PanTool\"},{\"attributes\":{\"data_source\":{\"id\":\"2695\"},\"glyph\":{\"id\":\"2727\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"2728\"},\"selection_glyph\":null,\"view\":{\"id\":\"2730\"}},\"id\":\"2729\",\"type\":\"GlyphRenderer\"}],\"root_ids\":[\"2696\"]},\"title\":\"Bokeh Application\",\"version\":\"2.1.1\"}};\n",
" var render_items = [{\"docid\":\"1a5e8f14-b2bf-4035-a334-165f6fb81ca7\",\"root_ids\":[\"2696\"],\"roots\":{\"2696\":\"33e2a8ce-0beb-4ed8-9555-61437e5ce818\"}}];\n",
" root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n",
"\n",
" }\n",
" if (root.Bokeh !== undefined) {\n",
" embed_document(root);\n",
" } else {\n",
" var attempts = 0;\n",
" var timer = setInterval(function(root) {\n",
" if (root.Bokeh !== undefined) {\n",
" clearInterval(timer);\n",
" embed_document(root);\n",
" } else {\n",
" attempts++;\n",
" if (attempts > 100) {\n",
" clearInterval(timer);\n",
" console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n",
" }\n",
" }\n",
" }, 10, root)\n",
" }\n",
"})(window);"
],
"application/vnd.bokehjs_exec.v0+json": ""
},
"metadata": {
"tags": [],
"application/vnd.bokehjs_exec.v0+json": {
"id": "2696"
}
}
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "-c7HNevj1pYv"
},
"source": [
"## Comparación por género"
]
},
{
"cell_type": "code",
"metadata": {
"id": "5W75W1-Q1pYv",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 787
},
"outputId": "c5e04cfc-c336-4755-e5db-a279a3662a65"
},
"source": [
"# Agrupamos por experiencia y género. Llenamos con 0 los grupos sin valores.\n",
"gender = df.groupby(['exp_bin', 'gender'])['salarymx'].agg(['median','count']).fillna(0)\n",
"gender.head(25)"
],
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th></th>\n",
" <th>median</th>\n",
" <th>count</th>\n",
" </tr>\n",
" <tr>\n",
" <th>exp_bin</th>\n",
" <th>gender</th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th rowspan=\"3\" valign=\"top\">(-0.1, 2.0]</th>\n",
" <th>hombre</th>\n",
" <td>18000.0</td>\n",
" <td>117</td>\n",
" </tr>\n",
" <tr>\n",
" <th>mujer</th>\n",
" <td>16500.0</td>\n",
" <td>68</td>\n",
" </tr>\n",
" <tr>\n",
" <th>nb</th>\n",
" <td>18000.0</td>\n",
" <td>5</td>\n",
" </tr>\n",
" <tr>\n",
" <th rowspan=\"3\" valign=\"top\">(2.0, 4.0]</th>\n",
" <th>hombre</th>\n",
" <td>33000.0</td>\n",
" <td>140</td>\n",
" </tr>\n",
" <tr>\n",
" <th>mujer</th>\n",
" <td>23248.0</td>\n",
" <td>68</td>\n",
" </tr>\n",
" <tr>\n",
" <th>nb</th>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th rowspan=\"3\" valign=\"top\">(4.0, 6.0]</th>\n",
" <th>hombre</th>\n",
" <td>42000.0</td>\n",
" <td>187</td>\n",
" </tr>\n",
" <tr>\n",
" <th>mujer</th>\n",
" <td>29000.0</td>\n",
" <td>54</td>\n",
" </tr>\n",
" <tr>\n",
" <th>nb</th>\n",
" <td>48000.0</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th rowspan=\"3\" valign=\"top\">(6.0, 8.0]</th>\n",
" <th>hombre</th>\n",
" <td>47700.0</td>\n",
" <td>134</td>\n",
" </tr>\n",
" <tr>\n",
" <th>mujer</th>\n",
" <td>39000.0</td>\n",
" <td>37</td>\n",
" </tr>\n",
" <tr>\n",
" <th>nb</th>\n",
" <td>80000.0</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th rowspan=\"3\" valign=\"top\">(8.0, 10.0]</th>\n",
" <th>hombre</th>\n",
" <td>57000.0</td>\n",
" <td>121</td>\n",
" </tr>\n",
" <tr>\n",
" <th>mujer</th>\n",
" <td>39000.0</td>\n",
" <td>28</td>\n",
" </tr>\n",
" <tr>\n",
" <th>nb</th>\n",
" <td>97000.0</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th rowspan=\"3\" valign=\"top\">(10.0, 14.0]</th>\n",
" <th>hombre</th>\n",
" <td>55000.0</td>\n",
" <td>148</td>\n",
" </tr>\n",
" <tr>\n",
" <th>mujer</th>\n",
" <td>50000.0</td>\n",
" <td>40</td>\n",
" </tr>\n",
" <tr>\n",
" <th>nb</th>\n",
" <td>45000.0</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th rowspan=\"3\" valign=\"top\">(14.0, 20.0]</th>\n",
" <th>hombre</th>\n",
" <td>55000.0</td>\n",
" <td>183</td>\n",
" </tr>\n",
" <tr>\n",
" <th>mujer</th>\n",
" <td>40000.0</td>\n",
" <td>28</td>\n",
" </tr>\n",
" <tr>\n",
" <th>nb</th>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th rowspan=\"3\" valign=\"top\">(20.0, 40.0]</th>\n",
" <th>hombre</th>\n",
" <td>52300.0</td>\n",
" <td>128</td>\n",
" </tr>\n",
" <tr>\n",
" <th>mujer</th>\n",
" <td>35000.0</td>\n",
" <td>25</td>\n",
" </tr>\n",
" <tr>\n",
" <th>nb</th>\n",
" <td>50000.0</td>\n",
" <td>1</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" median count\n",
"exp_bin gender \n",
"(-0.1, 2.0] hombre 18000.0 117\n",
" mujer 16500.0 68\n",
" nb 18000.0 5\n",
"(2.0, 4.0] hombre 33000.0 140\n",
" mujer 23248.0 68\n",
" nb 0.0 0\n",
"(4.0, 6.0] hombre 42000.0 187\n",
" mujer 29000.0 54\n",
" nb 48000.0 1\n",
"(6.0, 8.0] hombre 47700.0 134\n",
" mujer 39000.0 37\n",
" nb 80000.0 1\n",
"(8.0, 10.0] hombre 57000.0 121\n",
" mujer 39000.0 28\n",
" nb 97000.0 1\n",
"(10.0, 14.0] hombre 55000.0 148\n",
" mujer 50000.0 40\n",
" nb 45000.0 1\n",
"(14.0, 20.0] hombre 55000.0 183\n",
" mujer 40000.0 28\n",
" nb 0.0 0\n",
"(20.0, 40.0] hombre 52300.0 128\n",
" mujer 35000.0 25\n",
" nb 50000.0 1"
]
},
"metadata": {
"tags": []
},
"execution_count": 8
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "J0_SQBDq1pYw",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 284
},
"outputId": "4df9f254-c438-471e-9e22-3040b9272dc2"
},
"source": [
"# El dataframe que arroja el groupby no se presta a graficar, así que lo reacomodamos en uno nuevo.\n",
"# El número de observaciones de género no binario es muy bajo y no arroja datos robustos así que lo omitiré.\n",
"data = {\n",
" 'exp': exp_labels,\n",
" 'hombre_salary' : list(gender.xs('hombre',level=1)['median']),\n",
" 'hombre_count' : list(gender.xs('hombre',level=1)['count']),\n",
" 'mujer_salary' : list(gender.xs('mujer',level=1)['median']),\n",
" 'mujer_count' : list(gender.xs('mujer',level=1)['count'])\n",
"}\n",
"genderdf = pd.DataFrame(data)\n",
"genderdf.head(10)"
],
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>exp</th>\n",
" <th>hombre_salary</th>\n",
" <th>hombre_count</th>\n",
" <th>mujer_salary</th>\n",
" <th>mujer_count</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>0-2</td>\n",
" <td>18000.0</td>\n",
" <td>117</td>\n",
" <td>16500.0</td>\n",
" <td>68</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>3-4</td>\n",
" <td>33000.0</td>\n",
" <td>140</td>\n",
" <td>23248.0</td>\n",
" <td>68</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>5-6</td>\n",
" <td>42000.0</td>\n",
" <td>187</td>\n",
" <td>29000.0</td>\n",
" <td>54</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>7-8</td>\n",
" <td>47700.0</td>\n",
" <td>134</td>\n",
" <td>39000.0</td>\n",
" <td>37</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>9-10</td>\n",
" <td>57000.0</td>\n",
" <td>121</td>\n",
" <td>39000.0</td>\n",
" <td>28</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>11-14</td>\n",
" <td>55000.0</td>\n",
" <td>148</td>\n",
" <td>50000.0</td>\n",
" <td>40</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>15-20</td>\n",
" <td>55000.0</td>\n",
" <td>183</td>\n",
" <td>40000.0</td>\n",
" <td>28</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>20+</td>\n",
" <td>52300.0</td>\n",
" <td>128</td>\n",
" <td>35000.0</td>\n",
" <td>25</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" exp hombre_salary hombre_count mujer_salary mujer_count\n",
"0 0-2 18000.0 117 16500.0 68\n",
"1 3-4 33000.0 140 23248.0 68\n",
"2 5-6 42000.0 187 29000.0 54\n",
"3 7-8 47700.0 134 39000.0 37\n",
"4 9-10 57000.0 121 39000.0 28\n",
"5 11-14 55000.0 148 50000.0 40\n",
"6 15-20 55000.0 183 40000.0 28\n",
"7 20+ 52300.0 128 35000.0 25"
]
},
"metadata": {
"tags": []
},
"execution_count": 9
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "As9tzdyC1pYw",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 417
},
"outputId": "e0b66963-6ac5-44ea-ea92-0afb8bbc1072"
},
"source": [
"# Teniendo esta estructura más amigable procedamos a generar lineas con sus tooltips.\n",
"src = ColumnDataSource(genderdf)\n",
"p = figure(x_range=exp_labels, plot_height=400)\n",
"\n",
"renderer = p.line(x='exp',y='hombre_salary', source=src, color ='#1f77b4', line_width=2, legend_label='hombre')\n",
"p.add_tools(HoverTool(\n",
" renderers=[renderer],\n",
" tooltips=[\n",
" ('Género', 'Hombre'),\n",
" ('Experiencia', '@exp años'),\n",
" ('Observaciones', '@hombre_count'),\n",
" ('Salario', '@hombre_salary{$0,0}')\n",
" ]\n",
" ))\n",
"\n",
"renderer = p.line(x='exp',y='mujer_salary', source=src, color ='#e617e6', line_width=2, legend_label='mujer')\n",
"p.add_tools(HoverTool(\n",
" renderers=[renderer],\n",
" tooltips=[\n",
" ('Género', 'Mujer'),\n",
" ('Experiencia', '@exp años'),\n",
" ('Observaciones', '@mujer_count'),\n",
" ('Salario', '@mujer_salary{$0,0}')\n",
" ]\n",
" ))\n",
"\n",
"\n",
"p.title.text = 'Comparativo por género'\n",
"p.xaxis.axis_label = 'Experiencia (años)'\n",
"p.yaxis.axis_label = 'Salario bruto mensual (MXN)'\n",
"p.yaxis.formatter = NumeralTickFormatter(format='$0 a')\n",
"p.legend.location = \"bottom_right\"\n",
"\n",
"show(p)\n"
],
"execution_count": null,
"outputs": [
{
"output_type": "display_data",
"data": {
"application/javascript": [
"\n",
"(function(root) {\n",
" function now() {\n",
" return new Date();\n",
" }\n",
"\n",
" var force = true;\n",
"\n",
" if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n",
" root._bokeh_onload_callbacks = [];\n",
" root._bokeh_is_loading = undefined;\n",
" }\n",
"\n",
" var JS_MIME_TYPE = 'application/javascript';\n",
" var HTML_MIME_TYPE = 'text/html';\n",
" var EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n",
" var CLASS_NAME = 'output_bokeh rendered_html';\n",
"\n",
" /**\n",
" * Render data to the DOM node\n",
" */\n",
" function render(props, node) {\n",
" var script = document.createElement(\"script\");\n",
" node.appendChild(script);\n",
" }\n",
"\n",
" /**\n",
" * Handle when an output is cleared or removed\n",
" */\n",
" function handleClearOutput(event, handle) {\n",
" var cell = handle.cell;\n",
"\n",
" var id = cell.output_area._bokeh_element_id;\n",
" var server_id = cell.output_area._bokeh_server_id;\n",
" // Clean up Bokeh references\n",
" if (id != null && id in Bokeh.index) {\n",
" Bokeh.index[id].model.document.clear();\n",
" delete Bokeh.index[id];\n",
" }\n",
"\n",
" if (server_id !== undefined) {\n",
" // Clean up Bokeh references\n",
" var cmd = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n",
" cell.notebook.kernel.execute(cmd, {\n",
" iopub: {\n",
" output: function(msg) {\n",
" var id = msg.content.text.trim();\n",
" if (id in Bokeh.index) {\n",
" Bokeh.index[id].model.document.clear();\n",
" delete Bokeh.index[id];\n",
" }\n",
" }\n",
" }\n",
" });\n",
" // Destroy server and session\n",
" var cmd = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n",
" cell.notebook.kernel.execute(cmd);\n",
" }\n",
" }\n",
"\n",
" /**\n",
" * Handle when a new output is added\n",
" */\n",
" function handleAddOutput(event, handle) {\n",
" var output_area = handle.output_area;\n",
" var output = handle.output;\n",
"\n",
" // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n",
" if ((output.output_type != \"display_data\") || (!output.data.hasOwnProperty(EXEC_MIME_TYPE))) {\n",
" return\n",
" }\n",
"\n",
" var toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n",
"\n",
" if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n",
" toinsert[toinsert.length - 1].firstChild.textContent = output.data[JS_MIME_TYPE];\n",
" // store reference to embed id on output_area\n",
" output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n",
" }\n",
" if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n",
" var bk_div = document.createElement(\"div\");\n",
" bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n",
" var script_attrs = bk_div.children[0].attributes;\n",
" for (var i = 0; i < script_attrs.length; i++) {\n",
" toinsert[toinsert.length - 1].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n",
" toinsert[toinsert.length - 1].firstChild.textContent = bk_div.children[0].textContent\n",
" }\n",
" // store reference to server id on output_area\n",
" output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n",
" }\n",
" }\n",
"\n",
" function register_renderer(events, OutputArea) {\n",
"\n",
" function append_mime(data, metadata, element) {\n",
" // create a DOM node to render to\n",
" var toinsert = this.create_output_subarea(\n",
" metadata,\n",
" CLASS_NAME,\n",
" EXEC_MIME_TYPE\n",
" );\n",
" this.keyboard_manager.register_events(toinsert);\n",
" // Render to node\n",
" var props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n",
" render(props, toinsert[toinsert.length - 1]);\n",
" element.append(toinsert);\n",
" return toinsert\n",
" }\n",
"\n",
" /* Handle when an output is cleared or removed */\n",
" events.on('clear_output.CodeCell', handleClearOutput);\n",
" events.on('delete.Cell', handleClearOutput);\n",
"\n",
" /* Handle when a new output is added */\n",
" events.on('output_added.OutputArea', handleAddOutput);\n",
"\n",
" /**\n",
" * Register the mime type and append_mime function with output_area\n",
" */\n",
" OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n",
" /* Is output safe? */\n",
" safe: true,\n",
" /* Index of renderer in `output_area.display_order` */\n",
" index: 0\n",
" });\n",
" }\n",
"\n",
" // register the mime type if in Jupyter Notebook environment and previously unregistered\n",
" if (root.Jupyter !== undefined) {\n",
" var events = require('base/js/events');\n",
" var OutputArea = require('notebook/js/outputarea').OutputArea;\n",
"\n",
" if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n",
" register_renderer(events, OutputArea);\n",
" }\n",
" }\n",
"\n",
" \n",
" if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n",
" root._bokeh_timeout = Date.now() + 5000;\n",
" root._bokeh_failed_load = false;\n",
" }\n",
"\n",
" var NB_LOAD_WARNING = {'data': {'text/html':\n",
" \"<div style='background-color: #fdd'>\\n\"+\n",
" \"<p>\\n\"+\n",
" \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n",
" \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n",
" \"</p>\\n\"+\n",
" \"<ul>\\n\"+\n",
" \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n",
" \"<li>use INLINE resources instead, as so:</li>\\n\"+\n",
" \"</ul>\\n\"+\n",
" \"<code>\\n\"+\n",
" \"from bokeh.resources import INLINE\\n\"+\n",
" \"output_notebook(resources=INLINE)\\n\"+\n",
" \"</code>\\n\"+\n",
" \"</div>\"}};\n",
"\n",
" function display_loaded() {\n",
" var el = document.getElementById(null);\n",
" if (el != null) {\n",
" el.textContent = \"BokehJS is loading...\";\n",
" }\n",
" if (root.Bokeh !== undefined) {\n",
" if (el != null) {\n",
" el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n",
" }\n",
" } else if (Date.now() < root._bokeh_timeout) {\n",
" setTimeout(display_loaded, 100)\n",
" }\n",
" }\n",
"\n",
"\n",
" function run_callbacks() {\n",
" try {\n",
" root._bokeh_onload_callbacks.forEach(function(callback) {\n",
" if (callback != null)\n",
" callback();\n",
" });\n",
" } finally {\n",
" delete root._bokeh_onload_callbacks\n",
" }\n",
" console.debug(\"Bokeh: all callbacks have finished\");\n",
" }\n",
"\n",
" function load_libs(css_urls, js_urls, callback) {\n",
" if (css_urls == null) css_urls = [];\n",
" if (js_urls == null) js_urls = [];\n",
"\n",
" root._bokeh_onload_callbacks.push(callback);\n",
" if (root._bokeh_is_loading > 0) {\n",
" console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n",
" return null;\n",
" }\n",
" if (js_urls == null || js_urls.length === 0) {\n",
" run_callbacks();\n",
" return null;\n",
" }\n",
" console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n",
" root._bokeh_is_loading = css_urls.length + js_urls.length;\n",
"\n",
" function on_load() {\n",
" root._bokeh_is_loading--;\n",
" if (root._bokeh_is_loading === 0) {\n",
" console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n",
" run_callbacks()\n",
" }\n",
" }\n",
"\n",
" function on_error() {\n",
" console.error(\"failed to load \" + url);\n",
" }\n",
"\n",
" for (var i = 0; i < css_urls.length; i++) {\n",
" var url = css_urls[i];\n",
" const element = document.createElement(\"link\");\n",
" element.onload = on_load;\n",
" element.onerror = on_error;\n",
" element.rel = \"stylesheet\";\n",
" element.type = \"text/css\";\n",
" element.href = url;\n",
" console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n",
" document.body.appendChild(element);\n",
" }\n",
"\n",
" const hashes = {\"https://cdn.bokeh.org/bokeh/release/bokeh-2.1.1.min.js\": \"kLr4fYcqcSpbuI95brIH3vnnYCquzzSxHPU6XGQCIkQRGJwhg0StNbj1eegrHs12\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.1.1.min.js\": \"xIGPmVtaOm+z0BqfSOMn4lOR6ciex448GIKG4eE61LsAvmGj48XcMQZtKcE/UXZe\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.1.1.min.js\": \"Dc9u1wF/0zApGIWoBbH77iWEHtdmkuYWG839Uzmv8y8yBLXebjO9ZnERsde5Ln/P\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.1.1.min.js\": \"cT9JaBz7GiRXdENrJLZNSC6eMNF3nh3fa5fTF51Svp+ukxPdwcU5kGXGPBgDCa2j\"};\n",
"\n",
" for (var i = 0; i < js_urls.length; i++) {\n",
" var url = js_urls[i];\n",
" var element = document.createElement('script');\n",
" element.onload = on_load;\n",
" element.onerror = on_error;\n",
" element.async = false;\n",
" element.src = url;\n",
" if (url in hashes) {\n",
" element.crossOrigin = \"anonymous\";\n",
" element.integrity = \"sha384-\" + hashes[url];\n",
" }\n",
" console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n",
" document.head.appendChild(element);\n",
" }\n",
" };\n",
"\n",
" function inject_raw_css(css) {\n",
" const element = document.createElement(\"style\");\n",
" element.appendChild(document.createTextNode(css));\n",
" document.body.appendChild(element);\n",
" }\n",
"\n",
" \n",
" var js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.1.1.min.js\"];\n",
" var css_urls = [];\n",
" \n",
"\n",
" var inline_js = [\n",
" function(Bokeh) {\n",
" Bokeh.set_log_level(\"info\");\n",
" },\n",
" function(Bokeh) {\n",
" \n",
" \n",
" }\n",
" ];\n",
"\n",
" function run_inline_js() {\n",
" \n",
" if (root.Bokeh !== undefined || force === true) {\n",
" \n",
" for (var i = 0; i < inline_js.length; i++) {\n",
" inline_js[i].call(root, root.Bokeh);\n",
" }\n",
" } else if (Date.now() < root._bokeh_timeout) {\n",
" setTimeout(run_inline_js, 100);\n",
" } else if (!root._bokeh_failed_load) {\n",
" console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n",
" root._bokeh_failed_load = true;\n",
" } else if (force !== true) {\n",
" var cell = $(document.getElementById(null)).parents('.cell').data().cell;\n",
" cell.output_area.append_execute_result(NB_LOAD_WARNING)\n",
" }\n",
"\n",
" }\n",
"\n",
" if (root._bokeh_is_loading === 0) {\n",
" console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n",
" run_inline_js();\n",
" } else {\n",
" load_libs(css_urls, js_urls, function() {\n",
" console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n",
" run_inline_js();\n",
" });\n",
" }\n",
"}(window));"
],
"application/vnd.bokehjs_load.v0+json": "\n(function(root) {\n function now() {\n return new Date();\n }\n\n var force = true;\n\n if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\n \n\n \n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n var NB_LOAD_WARNING = {'data': {'text/html':\n \"<div style='background-color: #fdd'>\\n\"+\n \"<p>\\n\"+\n \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n \"</p>\\n\"+\n \"<ul>\\n\"+\n \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n \"<li>use INLINE resources instead, as so:</li>\\n\"+\n \"</ul>\\n\"+\n \"<code>\\n\"+\n \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"</code>\\n\"+\n \"</div>\"}};\n\n function display_loaded() {\n var el = document.getElementById(null);\n if (el != null) {\n el.textContent = \"BokehJS is loading...\";\n }\n if (root.Bokeh !== undefined) {\n if (el != null) {\n el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(display_loaded, 100)\n }\n }\n\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) {\n if (callback != null)\n callback();\n });\n } finally {\n delete root._bokeh_onload_callbacks\n }\n console.debug(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(css_urls, js_urls, callback) {\n if (css_urls == null) css_urls = [];\n if (js_urls == null) js_urls = [];\n\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls == null || js_urls.length === 0) {\n run_callbacks();\n return null;\n }\n console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n root._bokeh_is_loading = css_urls.length + js_urls.length;\n\n function on_load() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n run_callbacks()\n }\n }\n\n function on_error() {\n console.error(\"failed to load \" + url);\n }\n\n for (var i = 0; i < css_urls.length; i++) {\n var url = css_urls[i];\n const element = document.createElement(\"link\");\n element.onload = on_load;\n element.onerror = on_error;\n element.rel = \"stylesheet\";\n element.type = \"text/css\";\n element.href = url;\n console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n document.body.appendChild(element);\n }\n\n const hashes = {\"https://cdn.bokeh.org/bokeh/release/bokeh-2.1.1.min.js\": \"kLr4fYcqcSpbuI95brIH3vnnYCquzzSxHPU6XGQCIkQRGJwhg0StNbj1eegrHs12\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.1.1.min.js\": \"xIGPmVtaOm+z0BqfSOMn4lOR6ciex448GIKG4eE61LsAvmGj48XcMQZtKcE/UXZe\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.1.1.min.js\": \"Dc9u1wF/0zApGIWoBbH77iWEHtdmkuYWG839Uzmv8y8yBLXebjO9ZnERsde5Ln/P\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.1.1.min.js\": \"cT9JaBz7GiRXdENrJLZNSC6eMNF3nh3fa5fTF51Svp+ukxPdwcU5kGXGPBgDCa2j\"};\n\n for (var i = 0; i < js_urls.length; i++) {\n var url = js_urls[i];\n var element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error;\n element.async = false;\n element.src = url;\n if (url in hashes) {\n element.crossOrigin = \"anonymous\";\n element.integrity = \"sha384-\" + hashes[url];\n }\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n };\n\n function inject_raw_css(css) {\n const element = document.createElement(\"style\");\n element.appendChild(document.createTextNode(css));\n document.body.appendChild(element);\n }\n\n \n var js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.1.1.min.js\"];\n var css_urls = [];\n \n\n var inline_js = [\n function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\n function(Bokeh) {\n \n \n }\n ];\n\n function run_inline_js() {\n \n if (root.Bokeh !== undefined || force === true) {\n \n for (var i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n } else if (force !== true) {\n var cell = $(document.getElementById(null)).parents('.cell').data().cell;\n cell.output_area.append_execute_result(NB_LOAD_WARNING)\n }\n\n }\n\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(css_urls, js_urls, function() {\n console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));"
},
"metadata": {
"tags": []
}
},
{
"output_type": "display_data",
"data": {
"text/html": [
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
" <div class=\"bk-root\" id=\"abefdec1-6725-4984-9037-bb51b6154314\" data-root-id=\"1099\"></div>\n"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "display_data",
"data": {
"application/javascript": [
"(function(root) {\n",
" function embed_document(root) {\n",
" \n",
" var docs_json = {\"f4d55ece-e084-4825-8726-2d41180be753\":{\"roots\":{\"references\":[{\"attributes\":{\"below\":[{\"id\":\"1108\"}],\"center\":[{\"id\":\"1110\"},{\"id\":\"1114\"},{\"id\":\"1143\"}],\"left\":[{\"id\":\"1111\"}],\"plot_height\":400,\"renderers\":[{\"id\":\"1132\"},{\"id\":\"1150\"}],\"title\":{\"id\":\"1135\"},\"toolbar\":{\"id\":\"1122\"},\"x_range\":{\"id\":\"1100\"},\"x_scale\":{\"id\":\"1104\"},\"y_range\":{\"id\":\"1102\"},\"y_scale\":{\"id\":\"1106\"}},\"id\":\"1099\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{},\"id\":\"1102\",\"type\":\"DataRange1d\"},{\"attributes\":{\"text\":\"Comparativo por g\\u00e9nero\"},\"id\":\"1135\",\"type\":\"Title\"},{\"attributes\":{},\"id\":\"1116\",\"type\":\"WheelZoomTool\"},{\"attributes\":{\"label\":{\"value\":\"mujer\"},\"renderers\":[{\"id\":\"1150\"}]},\"id\":\"1161\",\"type\":\"LegendItem\"},{\"attributes\":{\"overlay\":{\"id\":\"1121\"}},\"id\":\"1117\",\"type\":\"BoxZoomTool\"},{\"attributes\":{},\"id\":\"1104\",\"type\":\"CategoricalScale\"},{\"attributes\":{\"factors\":[\"0-2\",\"3-4\",\"5-6\",\"7-8\",\"9-10\",\"11-14\",\"15-20\",\"20+\"]},\"id\":\"1100\",\"type\":\"FactorRange\"},{\"attributes\":{},\"id\":\"1118\",\"type\":\"SaveTool\"},{\"attributes\":{},\"id\":\"1141\",\"type\":\"Selection\"},{\"attributes\":{},\"id\":\"1119\",\"type\":\"ResetTool\"},{\"attributes\":{\"data_source\":{\"id\":\"1098\"},\"glyph\":{\"id\":\"1130\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"1131\"},\"selection_glyph\":null,\"view\":{\"id\":\"1133\"}},\"id\":\"1132\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"1120\",\"type\":\"HelpTool\"},{\"attributes\":{},\"id\":\"1106\",\"type\":\"LinearScale\"},{\"attributes\":{\"axis_label\":\"Experiencia (a\\u00f1os)\",\"formatter\":{\"id\":\"1138\"},\"ticker\":{\"id\":\"1109\"}},\"id\":\"1108\",\"type\":\"CategoricalAxis\"},{\"attributes\":{\"source\":{\"id\":\"1098\"}},\"id\":\"1151\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"1112\",\"type\":\"BasicTicker\"},{\"attributes\":{\"data_source\":{\"id\":\"1098\"},\"glyph\":{\"id\":\"1148\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"1149\"},\"selection_glyph\":null,\"view\":{\"id\":\"1151\"}},\"id\":\"1150\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"1109\",\"type\":\"CategoricalTicker\"},{\"attributes\":{\"line_alpha\":0.1,\"line_color\":\"#e617e6\",\"line_width\":2,\"x\":{\"field\":\"exp\"},\"y\":{\"field\":\"mujer_salary\"}},\"id\":\"1149\",\"type\":\"Line\"},{\"attributes\":{\"axis\":{\"id\":\"1108\"},\"ticker\":null},\"id\":\"1110\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"1138\",\"type\":\"CategoricalTickFormatter\"},{\"attributes\":{\"label\":{\"value\":\"hombre\"},\"renderers\":[{\"id\":\"1132\"}]},\"id\":\"1144\",\"type\":\"LegendItem\"},{\"attributes\":{\"axis\":{\"id\":\"1111\"},\"dimension\":1,\"ticker\":null},\"id\":\"1114\",\"type\":\"Grid\"},{\"attributes\":{\"format\":\"$0 a\"},\"id\":\"1165\",\"type\":\"NumeralTickFormatter\"},{\"attributes\":{\"axis_label\":\"Salario bruto mensual (MXN)\",\"formatter\":{\"id\":\"1165\"},\"ticker\":{\"id\":\"1112\"}},\"id\":\"1111\",\"type\":\"LinearAxis\"},{\"attributes\":{\"line_color\":\"#e617e6\",\"line_width\":2,\"x\":{\"field\":\"exp\"},\"y\":{\"field\":\"mujer_salary\"}},\"id\":\"1148\",\"type\":\"Line\"},{\"attributes\":{\"callback\":null,\"renderers\":[{\"id\":\"1150\"}],\"tooltips\":[[\"G\\u00e9nero\",\"Mujer\"],[\"Experiencia\",\"@exp a\\u00f1os\"],[\"Observaciones\",\"@mujer_count\"],[\"Salario\",\"@mujer_salary{$0,0}\"]]},\"id\":\"1162\",\"type\":\"HoverTool\"},{\"attributes\":{\"items\":[{\"id\":\"1144\"},{\"id\":\"1161\"}],\"location\":\"bottom_right\"},\"id\":\"1143\",\"type\":\"Legend\"},{\"attributes\":{\"callback\":null,\"renderers\":[{\"id\":\"1132\"}],\"tooltips\":[[\"G\\u00e9nero\",\"Hombre\"],[\"Experiencia\",\"@exp a\\u00f1os\"],[\"Observaciones\",\"@hombre_count\"],[\"Salario\",\"@hombre_salary{$0,0}\"]]},\"id\":\"1145\",\"type\":\"HoverTool\"},{\"attributes\":{},\"id\":\"1142\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"line_alpha\":0.1,\"line_color\":\"#1f77b4\",\"line_width\":2,\"x\":{\"field\":\"exp\"},\"y\":{\"field\":\"hombre_salary\"}},\"id\":\"1131\",\"type\":\"Line\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":0.5,\"fill_color\":\"lightgrey\",\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":1.0,\"line_color\":\"black\",\"line_dash\":[4,4],\"line_width\":2,\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"1121\",\"type\":\"BoxAnnotation\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_multi\":null,\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"1115\"},{\"id\":\"1116\"},{\"id\":\"1117\"},{\"id\":\"1118\"},{\"id\":\"1119\"},{\"id\":\"1120\"},{\"id\":\"1145\"},{\"id\":\"1162\"}]},\"id\":\"1122\",\"type\":\"Toolbar\"},{\"attributes\":{\"line_color\":\"#1f77b4\",\"line_width\":2,\"x\":{\"field\":\"exp\"},\"y\":{\"field\":\"hombre_salary\"}},\"id\":\"1130\",\"type\":\"Line\"},{\"attributes\":{\"data\":{\"exp\":[\"0-2\",\"3-4\",\"5-6\",\"7-8\",\"9-10\",\"11-14\",\"15-20\",\"20+\"],\"hombre_count\":[117,140,187,134,121,148,183,128],\"hombre_salary\":{\"__ndarray__\":\"AAAAAACU0UAAAAAAAB3gQAAAAAAAguRAAAAAAIBK50AAAAAAANXrQAAAAAAA2+pAAAAAAADb6kAAAAAAgInpQA==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[8]},\"index\":[0,1,2,3,4,5,6,7],\"mujer_count\":[68,68,54,37,28,40,28,25],\"mujer_salary\":{\"__ndarray__\":\"AAAAAAAd0EAAAAAAALTWQAAAAAAAUtxAAAAAAAAL40AAAAAAAAvjQAAAAAAAauhAAAAAAACI40AAAAAAABfhQA==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[8]}},\"selected\":{\"id\":\"1141\"},\"selection_policy\":{\"id\":\"1142\"}},\"id\":\"1098\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"source\":{\"id\":\"1098\"}},\"id\":\"1133\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"1115\",\"type\":\"PanTool\"}],\"root_ids\":[\"1099\"]},\"title\":\"Bokeh Application\",\"version\":\"2.1.1\"}};\n",
" var render_items = [{\"docid\":\"f4d55ece-e084-4825-8726-2d41180be753\",\"root_ids\":[\"1099\"],\"roots\":{\"1099\":\"abefdec1-6725-4984-9037-bb51b6154314\"}}];\n",
" root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n",
"\n",
" }\n",
" if (root.Bokeh !== undefined) {\n",
" embed_document(root);\n",
" } else {\n",
" var attempts = 0;\n",
" var timer = setInterval(function(root) {\n",
" if (root.Bokeh !== undefined) {\n",
" clearInterval(timer);\n",
" embed_document(root);\n",
" } else {\n",
" attempts++;\n",
" if (attempts > 100) {\n",
" clearInterval(timer);\n",
" console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n",
" }\n",
" }\n",
" }, 10, root)\n",
" }\n",
"})(window);"
],
"application/vnd.bokehjs_exec.v0+json": ""
},
"metadata": {
"tags": [],
"application/vnd.bokehjs_exec.v0+json": {
"id": "1099"
}
}
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "CSEoq43_1pYw",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 780
},
"outputId": "ee52720f-ec3b-4a37-aaf5-8cc12111aeba"
},
"source": [
"\n",
"gender = df[(df['experience'] > 0)].groupby([\"experience\", \"gender\"])['salarymx'].agg(['median','count'])\n",
"gender = gender.reset_index()\n",
"gender = gender[(gender['count'] > 4)]\n",
"gender['size'] = round(np.sqrt(gender['count']))*2\n",
"\n",
"# Agregamos una columna de color en base al valor de gender.\n",
"gender['color'] = ['#1f77b4' if x =='hombre' else '#e617e6' for x in gender['gender']] \n",
"\n",
"src = ColumnDataSource(gender)\n",
"p = figure(plot_height = 400, plot_width = 600, sizing_mode=\"scale_both\", toolbar_location=None)\n",
"p.toolbar.active_drag = None\n",
"p.toolbar.active_scroll = None\n",
"p.circle(x='experience', y='median', source=src, size='size', color='color')\n",
"p.title.text = 'Comparativo por género'\n",
"p.xaxis.axis_label = 'Experiencia (años)'\n",
"p.yaxis.axis_label = 'Salario bruto mensual (MXN)'\n",
"p.yaxis.formatter = NumeralTickFormatter(format='$0 a')\n",
"\n",
"hover = HoverTool()\n",
"hover.tooltips=[\n",
" ('Género', '@gender'), \n",
" ('Experiencia', '@experience años'),\n",
" ('Observaciones', '@count'),\n",
" ('Salario medio', '@median{$0,0}'),\n",
"]\n",
"\n",
"p.add_tools(hover)\n",
"show(p)"
],
"execution_count": null,
"outputs": [
{
"output_type": "display_data",
"data": {
"application/javascript": [
"\n",
"(function(root) {\n",
" function now() {\n",
" return new Date();\n",
" }\n",
"\n",
" var force = true;\n",
"\n",
" if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n",
" root._bokeh_onload_callbacks = [];\n",
" root._bokeh_is_loading = undefined;\n",
" }\n",
"\n",
" var JS_MIME_TYPE = 'application/javascript';\n",
" var HTML_MIME_TYPE = 'text/html';\n",
" var EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n",
" var CLASS_NAME = 'output_bokeh rendered_html';\n",
"\n",
" /**\n",
" * Render data to the DOM node\n",
" */\n",
" function render(props, node) {\n",
" var script = document.createElement(\"script\");\n",
" node.appendChild(script);\n",
" }\n",
"\n",
" /**\n",
" * Handle when an output is cleared or removed\n",
" */\n",
" function handleClearOutput(event, handle) {\n",
" var cell = handle.cell;\n",
"\n",
" var id = cell.output_area._bokeh_element_id;\n",
" var server_id = cell.output_area._bokeh_server_id;\n",
" // Clean up Bokeh references\n",
" if (id != null && id in Bokeh.index) {\n",
" Bokeh.index[id].model.document.clear();\n",
" delete Bokeh.index[id];\n",
" }\n",
"\n",
" if (server_id !== undefined) {\n",
" // Clean up Bokeh references\n",
" var cmd = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n",
" cell.notebook.kernel.execute(cmd, {\n",
" iopub: {\n",
" output: function(msg) {\n",
" var id = msg.content.text.trim();\n",
" if (id in Bokeh.index) {\n",
" Bokeh.index[id].model.document.clear();\n",
" delete Bokeh.index[id];\n",
" }\n",
" }\n",
" }\n",
" });\n",
" // Destroy server and session\n",
" var cmd = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n",
" cell.notebook.kernel.execute(cmd);\n",
" }\n",
" }\n",
"\n",
" /**\n",
" * Handle when a new output is added\n",
" */\n",
" function handleAddOutput(event, handle) {\n",
" var output_area = handle.output_area;\n",
" var output = handle.output;\n",
"\n",
" // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n",
" if ((output.output_type != \"display_data\") || (!output.data.hasOwnProperty(EXEC_MIME_TYPE))) {\n",
" return\n",
" }\n",
"\n",
" var toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n",
"\n",
" if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n",
" toinsert[toinsert.length - 1].firstChild.textContent = output.data[JS_MIME_TYPE];\n",
" // store reference to embed id on output_area\n",
" output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n",
" }\n",
" if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n",
" var bk_div = document.createElement(\"div\");\n",
" bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n",
" var script_attrs = bk_div.children[0].attributes;\n",
" for (var i = 0; i < script_attrs.length; i++) {\n",
" toinsert[toinsert.length - 1].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n",
" toinsert[toinsert.length - 1].firstChild.textContent = bk_div.children[0].textContent\n",
" }\n",
" // store reference to server id on output_area\n",
" output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n",
" }\n",
" }\n",
"\n",
" function register_renderer(events, OutputArea) {\n",
"\n",
" function append_mime(data, metadata, element) {\n",
" // create a DOM node to render to\n",
" var toinsert = this.create_output_subarea(\n",
" metadata,\n",
" CLASS_NAME,\n",
" EXEC_MIME_TYPE\n",
" );\n",
" this.keyboard_manager.register_events(toinsert);\n",
" // Render to node\n",
" var props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n",
" render(props, toinsert[toinsert.length - 1]);\n",
" element.append(toinsert);\n",
" return toinsert\n",
" }\n",
"\n",
" /* Handle when an output is cleared or removed */\n",
" events.on('clear_output.CodeCell', handleClearOutput);\n",
" events.on('delete.Cell', handleClearOutput);\n",
"\n",
" /* Handle when a new output is added */\n",
" events.on('output_added.OutputArea', handleAddOutput);\n",
"\n",
" /**\n",
" * Register the mime type and append_mime function with output_area\n",
" */\n",
" OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n",
" /* Is output safe? */\n",
" safe: true,\n",
" /* Index of renderer in `output_area.display_order` */\n",
" index: 0\n",
" });\n",
" }\n",
"\n",
" // register the mime type if in Jupyter Notebook environment and previously unregistered\n",
" if (root.Jupyter !== undefined) {\n",
" var events = require('base/js/events');\n",
" var OutputArea = require('notebook/js/outputarea').OutputArea;\n",
"\n",
" if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n",
" register_renderer(events, OutputArea);\n",
" }\n",
" }\n",
"\n",
" \n",
" if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n",
" root._bokeh_timeout = Date.now() + 5000;\n",
" root._bokeh_failed_load = false;\n",
" }\n",
"\n",
" var NB_LOAD_WARNING = {'data': {'text/html':\n",
" \"<div style='background-color: #fdd'>\\n\"+\n",
" \"<p>\\n\"+\n",
" \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n",
" \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n",
" \"</p>\\n\"+\n",
" \"<ul>\\n\"+\n",
" \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n",
" \"<li>use INLINE resources instead, as so:</li>\\n\"+\n",
" \"</ul>\\n\"+\n",
" \"<code>\\n\"+\n",
" \"from bokeh.resources import INLINE\\n\"+\n",
" \"output_notebook(resources=INLINE)\\n\"+\n",
" \"</code>\\n\"+\n",
" \"</div>\"}};\n",
"\n",
" function display_loaded() {\n",
" var el = document.getElementById(null);\n",
" if (el != null) {\n",
" el.textContent = \"BokehJS is loading...\";\n",
" }\n",
" if (root.Bokeh !== undefined) {\n",
" if (el != null) {\n",
" el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n",
" }\n",
" } else if (Date.now() < root._bokeh_timeout) {\n",
" setTimeout(display_loaded, 100)\n",
" }\n",
" }\n",
"\n",
"\n",
" function run_callbacks() {\n",
" try {\n",
" root._bokeh_onload_callbacks.forEach(function(callback) {\n",
" if (callback != null)\n",
" callback();\n",
" });\n",
" } finally {\n",
" delete root._bokeh_onload_callbacks\n",
" }\n",
" console.debug(\"Bokeh: all callbacks have finished\");\n",
" }\n",
"\n",
" function load_libs(css_urls, js_urls, callback) {\n",
" if (css_urls == null) css_urls = [];\n",
" if (js_urls == null) js_urls = [];\n",
"\n",
" root._bokeh_onload_callbacks.push(callback);\n",
" if (root._bokeh_is_loading > 0) {\n",
" console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n",
" return null;\n",
" }\n",
" if (js_urls == null || js_urls.length === 0) {\n",
" run_callbacks();\n",
" return null;\n",
" }\n",
" console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n",
" root._bokeh_is_loading = css_urls.length + js_urls.length;\n",
"\n",
" function on_load() {\n",
" root._bokeh_is_loading--;\n",
" if (root._bokeh_is_loading === 0) {\n",
" console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n",
" run_callbacks()\n",
" }\n",
" }\n",
"\n",
" function on_error() {\n",
" console.error(\"failed to load \" + url);\n",
" }\n",
"\n",
" for (var i = 0; i < css_urls.length; i++) {\n",
" var url = css_urls[i];\n",
" const element = document.createElement(\"link\");\n",
" element.onload = on_load;\n",
" element.onerror = on_error;\n",
" element.rel = \"stylesheet\";\n",
" element.type = \"text/css\";\n",
" element.href = url;\n",
" console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n",
" document.body.appendChild(element);\n",
" }\n",
"\n",
" const hashes = {\"https://cdn.bokeh.org/bokeh/release/bokeh-2.1.1.min.js\": \"kLr4fYcqcSpbuI95brIH3vnnYCquzzSxHPU6XGQCIkQRGJwhg0StNbj1eegrHs12\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.1.1.min.js\": \"xIGPmVtaOm+z0BqfSOMn4lOR6ciex448GIKG4eE61LsAvmGj48XcMQZtKcE/UXZe\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.1.1.min.js\": \"Dc9u1wF/0zApGIWoBbH77iWEHtdmkuYWG839Uzmv8y8yBLXebjO9ZnERsde5Ln/P\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.1.1.min.js\": \"cT9JaBz7GiRXdENrJLZNSC6eMNF3nh3fa5fTF51Svp+ukxPdwcU5kGXGPBgDCa2j\"};\n",
"\n",
" for (var i = 0; i < js_urls.length; i++) {\n",
" var url = js_urls[i];\n",
" var element = document.createElement('script');\n",
" element.onload = on_load;\n",
" element.onerror = on_error;\n",
" element.async = false;\n",
" element.src = url;\n",
" if (url in hashes) {\n",
" element.crossOrigin = \"anonymous\";\n",
" element.integrity = \"sha384-\" + hashes[url];\n",
" }\n",
" console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n",
" document.head.appendChild(element);\n",
" }\n",
" };\n",
"\n",
" function inject_raw_css(css) {\n",
" const element = document.createElement(\"style\");\n",
" element.appendChild(document.createTextNode(css));\n",
" document.body.appendChild(element);\n",
" }\n",
"\n",
" \n",
" var js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.1.1.min.js\"];\n",
" var css_urls = [];\n",
" \n",
"\n",
" var inline_js = [\n",
" function(Bokeh) {\n",
" Bokeh.set_log_level(\"info\");\n",
" },\n",
" function(Bokeh) {\n",
" \n",
" \n",
" }\n",
" ];\n",
"\n",
" function run_inline_js() {\n",
" \n",
" if (root.Bokeh !== undefined || force === true) {\n",
" \n",
" for (var i = 0; i < inline_js.length; i++) {\n",
" inline_js[i].call(root, root.Bokeh);\n",
" }\n",
" } else if (Date.now() < root._bokeh_timeout) {\n",
" setTimeout(run_inline_js, 100);\n",
" } else if (!root._bokeh_failed_load) {\n",
" console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n",
" root._bokeh_failed_load = true;\n",
" } else if (force !== true) {\n",
" var cell = $(document.getElementById(null)).parents('.cell').data().cell;\n",
" cell.output_area.append_execute_result(NB_LOAD_WARNING)\n",
" }\n",
"\n",
" }\n",
"\n",
" if (root._bokeh_is_loading === 0) {\n",
" console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n",
" run_inline_js();\n",
" } else {\n",
" load_libs(css_urls, js_urls, function() {\n",
" console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n",
" run_inline_js();\n",
" });\n",
" }\n",
"}(window));"
],
"application/vnd.bokehjs_load.v0+json": "\n(function(root) {\n function now() {\n return new Date();\n }\n\n var force = true;\n\n if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\n \n\n \n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n var NB_LOAD_WARNING = {'data': {'text/html':\n \"<div style='background-color: #fdd'>\\n\"+\n \"<p>\\n\"+\n \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n \"</p>\\n\"+\n \"<ul>\\n\"+\n \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n \"<li>use INLINE resources instead, as so:</li>\\n\"+\n \"</ul>\\n\"+\n \"<code>\\n\"+\n \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"</code>\\n\"+\n \"</div>\"}};\n\n function display_loaded() {\n var el = document.getElementById(null);\n if (el != null) {\n el.textContent = \"BokehJS is loading...\";\n }\n if (root.Bokeh !== undefined) {\n if (el != null) {\n el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(display_loaded, 100)\n }\n }\n\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) {\n if (callback != null)\n callback();\n });\n } finally {\n delete root._bokeh_onload_callbacks\n }\n console.debug(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(css_urls, js_urls, callback) {\n if (css_urls == null) css_urls = [];\n if (js_urls == null) js_urls = [];\n\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls == null || js_urls.length === 0) {\n run_callbacks();\n return null;\n }\n console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n root._bokeh_is_loading = css_urls.length + js_urls.length;\n\n function on_load() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n run_callbacks()\n }\n }\n\n function on_error() {\n console.error(\"failed to load \" + url);\n }\n\n for (var i = 0; i < css_urls.length; i++) {\n var url = css_urls[i];\n const element = document.createElement(\"link\");\n element.onload = on_load;\n element.onerror = on_error;\n element.rel = \"stylesheet\";\n element.type = \"text/css\";\n element.href = url;\n console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n document.body.appendChild(element);\n }\n\n const hashes = {\"https://cdn.bokeh.org/bokeh/release/bokeh-2.1.1.min.js\": \"kLr4fYcqcSpbuI95brIH3vnnYCquzzSxHPU6XGQCIkQRGJwhg0StNbj1eegrHs12\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.1.1.min.js\": \"xIGPmVtaOm+z0BqfSOMn4lOR6ciex448GIKG4eE61LsAvmGj48XcMQZtKcE/UXZe\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.1.1.min.js\": \"Dc9u1wF/0zApGIWoBbH77iWEHtdmkuYWG839Uzmv8y8yBLXebjO9ZnERsde5Ln/P\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.1.1.min.js\": \"cT9JaBz7GiRXdENrJLZNSC6eMNF3nh3fa5fTF51Svp+ukxPdwcU5kGXGPBgDCa2j\"};\n\n for (var i = 0; i < js_urls.length; i++) {\n var url = js_urls[i];\n var element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error;\n element.async = false;\n element.src = url;\n if (url in hashes) {\n element.crossOrigin = \"anonymous\";\n element.integrity = \"sha384-\" + hashes[url];\n }\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n };\n\n function inject_raw_css(css) {\n const element = document.createElement(\"style\");\n element.appendChild(document.createTextNode(css));\n document.body.appendChild(element);\n }\n\n \n var js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.1.1.min.js\"];\n var css_urls = [];\n \n\n var inline_js = [\n function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\n function(Bokeh) {\n \n \n }\n ];\n\n function run_inline_js() {\n \n if (root.Bokeh !== undefined || force === true) {\n \n for (var i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n } else if (force !== true) {\n var cell = $(document.getElementById(null)).parents('.cell').data().cell;\n cell.output_area.append_execute_result(NB_LOAD_WARNING)\n }\n\n }\n\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(css_urls, js_urls, function() {\n console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));"
},
"metadata": {
"tags": []
}
},
{
"output_type": "display_data",
"data": {
"text/html": [
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
" <div class=\"bk-root\" id=\"c7fc8a39-2109-4512-8015-74793779ae67\" data-root-id=\"1232\"></div>\n"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "display_data",
"data": {
"application/javascript": [
"(function(root) {\n",
" function embed_document(root) {\n",
" \n",
" var docs_json = {\"d435a7c1-a45f-4910-a3ec-14ce37fa8b94\":{\"roots\":{\"references\":[{\"attributes\":{\"below\":[{\"id\":\"1241\"}],\"center\":[{\"id\":\"1244\"},{\"id\":\"1248\"}],\"left\":[{\"id\":\"1245\"}],\"plot_height\":400,\"renderers\":[{\"id\":\"1268\"}],\"sizing_mode\":\"scale_both\",\"title\":{\"id\":\"1270\"},\"toolbar\":{\"id\":\"1256\"},\"toolbar_location\":null,\"x_range\":{\"id\":\"1233\"},\"x_scale\":{\"id\":\"1237\"},\"y_range\":{\"id\":\"1235\"},\"y_scale\":{\"id\":\"1239\"}},\"id\":\"1232\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"fill_color\":{\"field\":\"color\"},\"line_color\":{\"field\":\"color\"},\"size\":{\"field\":\"size\",\"units\":\"screen\"},\"x\":{\"field\":\"experience\"},\"y\":{\"field\":\"median\"}},\"id\":\"1266\",\"type\":\"Circle\"},{\"attributes\":{},\"id\":\"1250\",\"type\":\"WheelZoomTool\"},{\"attributes\":{},\"id\":\"1237\",\"type\":\"LinearScale\"},{\"attributes\":{\"overlay\":{\"id\":\"1255\"}},\"id\":\"1251\",\"type\":\"BoxZoomTool\"},{\"attributes\":{\"source\":{\"id\":\"1231\"}},\"id\":\"1269\",\"type\":\"CDSView\"},{\"attributes\":{\"data\":{\"color\":[\"#1f77b4\",\"#e617e6\",\"#1f77b4\",\"#e617e6\",\"#1f77b4\",\"#e617e6\",\"#1f77b4\",\"#e617e6\",\"#1f77b4\",\"#e617e6\",\"#1f77b4\",\"#e617e6\",\"#1f77b4\",\"#e617e6\",\"#1f77b4\",\"#e617e6\",\"#1f77b4\",\"#e617e6\",\"#1f77b4\",\"#e617e6\",\"#1f77b4\",\"#e617e6\",\"#1f77b4\",\"#e617e6\",\"#1f77b4\",\"#e617e6\",\"#1f77b4\",\"#e617e6\",\"#1f77b4\",\"#e617e6\",\"#1f77b4\",\"#1f77b4\",\"#1f77b4\",\"#e617e6\",\"#1f77b4\",\"#1f77b4\",\"#e617e6\",\"#1f77b4\",\"#1f77b4\",\"#1f77b4\",\"#1f77b4\",\"#e617e6\",\"#1f77b4\",\"#1f77b4\",\"#1f77b4\",\"#e617e6\",\"#1f77b4\"],\"count\":[45,21,64,44,73,36,67,32,115,33,72,21,58,21,76,16,42,14,79,14,36,8,50,14,36,9,26,9,58,8,19,17,22,5,11,56,8,13,26,10,25,5,8,5,10,6,9],\"experience\":[1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,14,14,15,15,16,17,18,18,19,20,20,21,22,23,25,25,26,28,30,30,32],\"gender\":[\"hombre\",\"mujer\",\"hombre\",\"mujer\",\"hombre\",\"mujer\",\"hombre\",\"mujer\",\"hombre\",\"mujer\",\"hombre\",\"mujer\",\"hombre\",\"mujer\",\"hombre\",\"mujer\",\"hombre\",\"mujer\",\"hombre\",\"mujer\",\"hombre\",\"mujer\",\"hombre\",\"mujer\",\"hombre\",\"mujer\",\"hombre\",\"mujer\",\"hombre\",\"mujer\",\"hombre\",\"hombre\",\"hombre\",\"mujer\",\"hombre\",\"hombre\",\"mujer\",\"hombre\",\"hombre\",\"hombre\",\"hombre\",\"mujer\",\"hombre\",\"hombre\",\"hombre\",\"mujer\",\"hombre\"],\"index\":[0,1,3,4,6,7,8,9,10,11,13,14,15,16,17,18,20,21,22,23,25,26,27,28,29,30,31,32,34,35,36,38,40,41,42,44,45,46,47,49,53,54,55,59,61,62,65],\"median\":{\"__ndarray__\":\"AAAAAABkyUAAAAAAAIjDQAAAAAAAfNVAAAAAAACI00AAAAAAAEzdQAAAAAAAiNNAAAAAAACU4UAAAAAAYJnaQAAAAAAAiONAAAAAAABY20AAAAAAAF7qQAAAAAAAC+NAAAAAAMBK6EAAAAAAABfhQAAAAAAA+eVAAAAAAAB85UAAAAAAgBnrQAAAAAAAguRAAAAAAADV60AAAAAAABHiQAAAAABAP+xAAAAAAIAj8UAAAAAA8MLuQAAAAACAMedAAAAAAAD55UAAAAAAAEzdQAAAAAAA5+hAAAAAAIDG40AAAAAAgBnrQAAAAAAATO1AAAAAAADh6UAAAAAAAIjzQAAAAAAAauhAAAAAAABM3UAAAAAAAMPuQAAAAACArudAAAAAAABM3UAAAAAAAGroQAAAAAAAauhAAAAAAADb6kAAAAAAAGroQAAAAAAAiONAAAAAAMBQ90AAAAAAAIjzQAAAAACAH+pAAAAAAABq2EAAAAAAAGroQA==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[47]},\"size\":{\"__ndarray__\":\"AAAAAAAALEAAAAAAAAAkQAAAAAAAADBAAAAAAAAALEAAAAAAAAAyQAAAAAAAAChAAAAAAAAAMEAAAAAAAAAoQAAAAAAAADZAAAAAAAAAKEAAAAAAAAAwQAAAAAAAACRAAAAAAAAAMEAAAAAAAAAkQAAAAAAAADJAAAAAAAAAIEAAAAAAAAAoQAAAAAAAACBAAAAAAAAAMkAAAAAAAAAgQAAAAAAAAChAAAAAAAAAGEAAAAAAAAAsQAAAAAAAACBAAAAAAAAAKEAAAAAAAAAYQAAAAAAAACRAAAAAAAAAGEAAAAAAAAAwQAAAAAAAABhAAAAAAAAAIEAAAAAAAAAgQAAAAAAAACRAAAAAAAAAEEAAAAAAAAAYQAAAAAAAACxAAAAAAAAAGEAAAAAAAAAgQAAAAAAAACRAAAAAAAAAGEAAAAAAAAAkQAAAAAAAABBAAAAAAAAAGEAAAAAAAAAQQAAAAAAAABhAAAAAAAAAEEAAAAAAAAAYQA==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[47]}},\"selected\":{\"id\":\"1297\"},\"selection_policy\":{\"id\":\"1298\"}},\"id\":\"1231\",\"type\":\"ColumnDataSource\"},{\"attributes\":{},\"id\":\"1252\",\"type\":\"SaveTool\"},{\"attributes\":{},\"id\":\"1246\",\"type\":\"BasicTicker\"},{\"attributes\":{},\"id\":\"1253\",\"type\":\"ResetTool\"},{\"attributes\":{\"axis\":{\"id\":\"1241\"},\"ticker\":null},\"id\":\"1244\",\"type\":\"Grid\"},{\"attributes\":{\"axis\":{\"id\":\"1245\"},\"dimension\":1,\"ticker\":null},\"id\":\"1248\",\"type\":\"Grid\"},{\"attributes\":{\"format\":\"$0 a\"},\"id\":\"1271\",\"type\":\"NumeralTickFormatter\"},{\"attributes\":{},\"id\":\"1298\",\"type\":\"UnionRenderers\"},{\"attributes\":{},\"id\":\"1254\",\"type\":\"HelpTool\"},{\"attributes\":{\"text\":\"Comparativo por g\\u00e9nero\"},\"id\":\"1270\",\"type\":\"Title\"},{\"attributes\":{},\"id\":\"1297\",\"type\":\"Selection\"},{\"attributes\":{},\"id\":\"1242\",\"type\":\"BasicTicker\"},{\"attributes\":{\"axis_label\":\"Salario bruto mensual (MXN)\",\"formatter\":{\"id\":\"1271\"},\"ticker\":{\"id\":\"1246\"}},\"id\":\"1245\",\"type\":\"LinearAxis\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"field\":\"color\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"field\":\"color\"},\"size\":{\"field\":\"size\",\"units\":\"screen\"},\"x\":{\"field\":\"experience\"},\"y\":{\"field\":\"median\"}},\"id\":\"1267\",\"type\":\"Circle\"},{\"attributes\":{\"axis_label\":\"Experiencia (a\\u00f1os)\",\"formatter\":{\"id\":\"1294\"},\"ticker\":{\"id\":\"1242\"}},\"id\":\"1241\",\"type\":\"LinearAxis\"},{\"attributes\":{\"callback\":null,\"tooltips\":[[\"G\\u00e9nero\",\"@gender\"],[\"Experiencia\",\"@experience a\\u00f1os\"],[\"Observaciones\",\"@count\"],[\"Salario medio\",\"@median{$0,0}\"]]},\"id\":\"1273\",\"type\":\"HoverTool\"},{\"attributes\":{},\"id\":\"1239\",\"type\":\"LinearScale\"},{\"attributes\":{},\"id\":\"1294\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"active_drag\":null,\"active_inspect\":\"auto\",\"active_multi\":null,\"active_scroll\":null,\"active_tap\":\"auto\",\"tools\":[{\"id\":\"1249\"},{\"id\":\"1250\"},{\"id\":\"1251\"},{\"id\":\"1252\"},{\"id\":\"1253\"},{\"id\":\"1254\"},{\"id\":\"1273\"}]},\"id\":\"1256\",\"type\":\"Toolbar\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":0.5,\"fill_color\":\"lightgrey\",\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":1.0,\"line_color\":\"black\",\"line_dash\":[4,4],\"line_width\":2,\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"1255\",\"type\":\"BoxAnnotation\"},{\"attributes\":{\"data_source\":{\"id\":\"1231\"},\"glyph\":{\"id\":\"1266\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"1267\"},\"selection_glyph\":null,\"view\":{\"id\":\"1269\"}},\"id\":\"1268\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"1249\",\"type\":\"PanTool\"},{\"attributes\":{},\"id\":\"1235\",\"type\":\"DataRange1d\"},{\"attributes\":{},\"id\":\"1233\",\"type\":\"DataRange1d\"}],\"root_ids\":[\"1232\"]},\"title\":\"Bokeh Application\",\"version\":\"2.1.1\"}};\n",
" var render_items = [{\"docid\":\"d435a7c1-a45f-4910-a3ec-14ce37fa8b94\",\"root_ids\":[\"1232\"],\"roots\":{\"1232\":\"c7fc8a39-2109-4512-8015-74793779ae67\"}}];\n",
" root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n",
"\n",
" }\n",
" if (root.Bokeh !== undefined) {\n",
" embed_document(root);\n",
" } else {\n",
" var attempts = 0;\n",
" var timer = setInterval(function(root) {\n",
" if (root.Bokeh !== undefined) {\n",
" clearInterval(timer);\n",
" embed_document(root);\n",
" } else {\n",
" attempts++;\n",
" if (attempts > 100) {\n",
" clearInterval(timer);\n",
" console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n",
" }\n",
" }\n",
" }, 10, root)\n",
" }\n",
"})(window);"
],
"application/vnd.bokehjs_exec.v0+json": ""
},
"metadata": {
"tags": [],
"application/vnd.bokehjs_exec.v0+json": {
"id": "1232"
}
}
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "ggDwQtqa1pYx",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 580
},
"outputId": "50a9768f-1138-4f0f-bcbc-8a42cef4ef74"
},
"source": [
"gx = pd.crosstab(index=df['city'], columns=df['gender'])\n",
"gx = gx[(gx['hombre'])>9]\n",
"gx"
],
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th>gender</th>\n",
" <th>hombre</th>\n",
" <th>mujer</th>\n",
" <th>nb</th>\n",
" </tr>\n",
" <tr>\n",
" <th>city</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>Aguascalientes</th>\n",
" <td>18</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>CDMX</th>\n",
" <td>375</td>\n",
" <td>160</td>\n",
" <td>5</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Chihuahua</th>\n",
" <td>11</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Colima</th>\n",
" <td>12</td>\n",
" <td>6</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Cuernavaca</th>\n",
" <td>14</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Culiacán</th>\n",
" <td>13</td>\n",
" <td>2</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Estado de México</th>\n",
" <td>31</td>\n",
" <td>11</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Guadalajara</th>\n",
" <td>174</td>\n",
" <td>36</td>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Hermosillo</th>\n",
" <td>33</td>\n",
" <td>7</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>León</th>\n",
" <td>16</td>\n",
" <td>5</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Monterrey</th>\n",
" <td>55</td>\n",
" <td>12</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Mérida</th>\n",
" <td>10</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Puebla</th>\n",
" <td>20</td>\n",
" <td>7</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Queretaro</th>\n",
" <td>11</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Querétaro</th>\n",
" <td>57</td>\n",
" <td>10</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>San Luis Potosí</th>\n",
" <td>29</td>\n",
" <td>5</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Tijuana</th>\n",
" <td>18</td>\n",
" <td>8</td>\n",
" <td>0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
"gender hombre mujer nb\n",
"city \n",
"Aguascalientes 18 0 1\n",
"CDMX 375 160 5\n",
"Chihuahua 11 3 0\n",
"Colima 12 6 0\n",
"Cuernavaca 14 1 0\n",
"Culiacán 13 2 0\n",
"Estado de México 31 11 0\n",
"Guadalajara 174 36 2\n",
"Hermosillo 33 7 0\n",
"León 16 5 0\n",
"Monterrey 55 12 0\n",
"Mérida 10 1 0\n",
"Puebla 20 7 0\n",
"Queretaro 11 1 0\n",
"Querétaro 57 10 0\n",
"San Luis Potosí 29 5 0\n",
"Tijuana 18 8 0"
]
},
"metadata": {
"tags": []
},
"execution_count": 14
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "-xotD6vi1pYx"
},
"source": [
"## Inglés"
]
},
{
"cell_type": "code",
"metadata": {
"id": "ze-qIcFR1pYy",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 254
},
"outputId": "3fa98a8e-47f5-49bc-fa9c-316286955e42"
},
"source": [
"ingles = df.groupby(\"english_label\")[\"salarymx\"].agg(['count', 'median', 'mean', 'std']).sort_values(by=['median'], ascending=False)\n",
"ingles.head(20)"
],
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>count</th>\n",
" <th>median</th>\n",
" <th>mean</th>\n",
" <th>std</th>\n",
" </tr>\n",
" <tr>\n",
" <th>english_label</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>Nativo o bilingue (ILR 5)</th>\n",
" <td>65</td>\n",
" <td>58000</td>\n",
" <td>68837.692308</td>\n",
" <td>47283.607452</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Avanzado: Puedo conversar y escribir sin problemas sobre cualquier tema (ILR 4)</th>\n",
" <td>381</td>\n",
" <td>56000</td>\n",
" <td>64356.351706</td>\n",
" <td>43043.974150</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Profesional: Puedo interactuar profesionalmente con colegas y clientes (ILR 3)</th>\n",
" <td>479</td>\n",
" <td>46000</td>\n",
" <td>49435.931106</td>\n",
" <td>28808.557900</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Limitado: Me doy a entender pero con errores de gramática (ILR 2)</th>\n",
" <td>438</td>\n",
" <td>30000</td>\n",
" <td>33285.404110</td>\n",
" <td>21215.584344</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Elemental: Sé lo básico para sobrevivir (ILR 1)</th>\n",
" <td>146</td>\n",
" <td>24900</td>\n",
" <td>30164.164384</td>\n",
" <td>24136.971577</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Ninguno (ILR 0)</th>\n",
" <td>7</td>\n",
" <td>22000</td>\n",
" <td>24285.714286</td>\n",
" <td>9604.066599</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" count ... std\n",
"english_label ... \n",
"Nativo o bilingue (ILR 5) 65 ... 47283.607452\n",
"Avanzado: Puedo conversar y escribir sin proble... 381 ... 43043.974150\n",
"Profesional: Puedo interactuar profesionalmente... 479 ... 28808.557900\n",
"Limitado: Me doy a entender pero con errores de... 438 ... 21215.584344\n",
"Elemental: Sé lo básico para sobrevivir (ILR 1) 146 ... 24136.971577\n",
"Ninguno (ILR 0) 7 ... 9604.066599\n",
"\n",
"[6 rows x 4 columns]"
]
},
"metadata": {
"tags": []
},
"execution_count": 15
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "l4p8B9u11pYy",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 417
},
"outputId": "b66d3b03-40ca-4351-c603-3f3669a4d349"
},
"source": [
"ingles = df.groupby(['english_num','exp_bin'])['salarymx'].agg(['median', 'count']).fillna(0)\n",
"data = {\n",
" 'exp': exp_labels,\n",
" 'Elemental': list(ingles.xs(1)['median']),\n",
" 'Limitado' : list(ingles.xs(2)['median']),\n",
" 'Profesional' : list(ingles.xs(3)['median']),\n",
" 'Avanzado' : list(ingles.xs(4)['median']),\n",
" 'Nativo' : list(ingles.xs(5)['median']) \n",
"}\n",
"\n",
"inglesdf = pd.DataFrame(data)\n",
"\n",
"src = ColumnDataSource(inglesdf)\n",
"\n",
"p = figure(x_range=exp_labels, plot_height=400, plot_width=600)\n",
"\n",
"for col_name, color in zip(list(inglesdf.columns), Dark2[6]):\n",
" if col_name == 'exp':\n",
" continue\n",
"\n",
" p.add_tools(HoverTool(\n",
" renderers= [p.line('exp', col_name, source=src, color=color, legend_label=col_name, line_width=2)],\n",
" tooltips=[\n",
" ('Ingles', col_name),\n",
" ('Salario', '@'+col_name+'{$0,0}')\n",
" ]\n",
" ))\n",
"\n",
"p.title.text = 'Salario de acuerdo al nivel de inglés'\n",
"p.xaxis.axis_label = 'Experiencia (años)'\n",
"p.yaxis.axis_label = 'Salario'\n",
"p.yaxis.formatter = NumeralTickFormatter(format='$0 a')\n",
"p.legend.location = \"top_left\"\n",
"\n",
" \n",
"show(p)\n"
],
"execution_count": null,
"outputs": [
{
"output_type": "display_data",
"data": {
"application/javascript": [
"\n",
"(function(root) {\n",
" function now() {\n",
" return new Date();\n",
" }\n",
"\n",
" var force = true;\n",
"\n",
" if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n",
" root._bokeh_onload_callbacks = [];\n",
" root._bokeh_is_loading = undefined;\n",
" }\n",
"\n",
" var JS_MIME_TYPE = 'application/javascript';\n",
" var HTML_MIME_TYPE = 'text/html';\n",
" var EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n",
" var CLASS_NAME = 'output_bokeh rendered_html';\n",
"\n",
" /**\n",
" * Render data to the DOM node\n",
" */\n",
" function render(props, node) {\n",
" var script = document.createElement(\"script\");\n",
" node.appendChild(script);\n",
" }\n",
"\n",
" /**\n",
" * Handle when an output is cleared or removed\n",
" */\n",
" function handleClearOutput(event, handle) {\n",
" var cell = handle.cell;\n",
"\n",
" var id = cell.output_area._bokeh_element_id;\n",
" var server_id = cell.output_area._bokeh_server_id;\n",
" // Clean up Bokeh references\n",
" if (id != null && id in Bokeh.index) {\n",
" Bokeh.index[id].model.document.clear();\n",
" delete Bokeh.index[id];\n",
" }\n",
"\n",
" if (server_id !== undefined) {\n",
" // Clean up Bokeh references\n",
" var cmd = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n",
" cell.notebook.kernel.execute(cmd, {\n",
" iopub: {\n",
" output: function(msg) {\n",
" var id = msg.content.text.trim();\n",
" if (id in Bokeh.index) {\n",
" Bokeh.index[id].model.document.clear();\n",
" delete Bokeh.index[id];\n",
" }\n",
" }\n",
" }\n",
" });\n",
" // Destroy server and session\n",
" var cmd = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n",
" cell.notebook.kernel.execute(cmd);\n",
" }\n",
" }\n",
"\n",
" /**\n",
" * Handle when a new output is added\n",
" */\n",
" function handleAddOutput(event, handle) {\n",
" var output_area = handle.output_area;\n",
" var output = handle.output;\n",
"\n",
" // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n",
" if ((output.output_type != \"display_data\") || (!output.data.hasOwnProperty(EXEC_MIME_TYPE))) {\n",
" return\n",
" }\n",
"\n",
" var toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n",
"\n",
" if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n",
" toinsert[toinsert.length - 1].firstChild.textContent = output.data[JS_MIME_TYPE];\n",
" // store reference to embed id on output_area\n",
" output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n",
" }\n",
" if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n",
" var bk_div = document.createElement(\"div\");\n",
" bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n",
" var script_attrs = bk_div.children[0].attributes;\n",
" for (var i = 0; i < script_attrs.length; i++) {\n",
" toinsert[toinsert.length - 1].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n",
" toinsert[toinsert.length - 1].firstChild.textContent = bk_div.children[0].textContent\n",
" }\n",
" // store reference to server id on output_area\n",
" output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n",
" }\n",
" }\n",
"\n",
" function register_renderer(events, OutputArea) {\n",
"\n",
" function append_mime(data, metadata, element) {\n",
" // create a DOM node to render to\n",
" var toinsert = this.create_output_subarea(\n",
" metadata,\n",
" CLASS_NAME,\n",
" EXEC_MIME_TYPE\n",
" );\n",
" this.keyboard_manager.register_events(toinsert);\n",
" // Render to node\n",
" var props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n",
" render(props, toinsert[toinsert.length - 1]);\n",
" element.append(toinsert);\n",
" return toinsert\n",
" }\n",
"\n",
" /* Handle when an output is cleared or removed */\n",
" events.on('clear_output.CodeCell', handleClearOutput);\n",
" events.on('delete.Cell', handleClearOutput);\n",
"\n",
" /* Handle when a new output is added */\n",
" events.on('output_added.OutputArea', handleAddOutput);\n",
"\n",
" /**\n",
" * Register the mime type and append_mime function with output_area\n",
" */\n",
" OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n",
" /* Is output safe? */\n",
" safe: true,\n",
" /* Index of renderer in `output_area.display_order` */\n",
" index: 0\n",
" });\n",
" }\n",
"\n",
" // register the mime type if in Jupyter Notebook environment and previously unregistered\n",
" if (root.Jupyter !== undefined) {\n",
" var events = require('base/js/events');\n",
" var OutputArea = require('notebook/js/outputarea').OutputArea;\n",
"\n",
" if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n",
" register_renderer(events, OutputArea);\n",
" }\n",
" }\n",
"\n",
" \n",
" if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n",
" root._bokeh_timeout = Date.now() + 5000;\n",
" root._bokeh_failed_load = false;\n",
" }\n",
"\n",
" var NB_LOAD_WARNING = {'data': {'text/html':\n",
" \"<div style='background-color: #fdd'>\\n\"+\n",
" \"<p>\\n\"+\n",
" \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n",
" \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n",
" \"</p>\\n\"+\n",
" \"<ul>\\n\"+\n",
" \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n",
" \"<li>use INLINE resources instead, as so:</li>\\n\"+\n",
" \"</ul>\\n\"+\n",
" \"<code>\\n\"+\n",
" \"from bokeh.resources import INLINE\\n\"+\n",
" \"output_notebook(resources=INLINE)\\n\"+\n",
" \"</code>\\n\"+\n",
" \"</div>\"}};\n",
"\n",
" function display_loaded() {\n",
" var el = document.getElementById(null);\n",
" if (el != null) {\n",
" el.textContent = \"BokehJS is loading...\";\n",
" }\n",
" if (root.Bokeh !== undefined) {\n",
" if (el != null) {\n",
" el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n",
" }\n",
" } else if (Date.now() < root._bokeh_timeout) {\n",
" setTimeout(display_loaded, 100)\n",
" }\n",
" }\n",
"\n",
"\n",
" function run_callbacks() {\n",
" try {\n",
" root._bokeh_onload_callbacks.forEach(function(callback) {\n",
" if (callback != null)\n",
" callback();\n",
" });\n",
" } finally {\n",
" delete root._bokeh_onload_callbacks\n",
" }\n",
" console.debug(\"Bokeh: all callbacks have finished\");\n",
" }\n",
"\n",
" function load_libs(css_urls, js_urls, callback) {\n",
" if (css_urls == null) css_urls = [];\n",
" if (js_urls == null) js_urls = [];\n",
"\n",
" root._bokeh_onload_callbacks.push(callback);\n",
" if (root._bokeh_is_loading > 0) {\n",
" console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n",
" return null;\n",
" }\n",
" if (js_urls == null || js_urls.length === 0) {\n",
" run_callbacks();\n",
" return null;\n",
" }\n",
" console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n",
" root._bokeh_is_loading = css_urls.length + js_urls.length;\n",
"\n",
" function on_load() {\n",
" root._bokeh_is_loading--;\n",
" if (root._bokeh_is_loading === 0) {\n",
" console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n",
" run_callbacks()\n",
" }\n",
" }\n",
"\n",
" function on_error() {\n",
" console.error(\"failed to load \" + url);\n",
" }\n",
"\n",
" for (var i = 0; i < css_urls.length; i++) {\n",
" var url = css_urls[i];\n",
" const element = document.createElement(\"link\");\n",
" element.onload = on_load;\n",
" element.onerror = on_error;\n",
" element.rel = \"stylesheet\";\n",
" element.type = \"text/css\";\n",
" element.href = url;\n",
" console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n",
" document.body.appendChild(element);\n",
" }\n",
"\n",
" const hashes = {\"https://cdn.bokeh.org/bokeh/release/bokeh-2.1.1.min.js\": \"kLr4fYcqcSpbuI95brIH3vnnYCquzzSxHPU6XGQCIkQRGJwhg0StNbj1eegrHs12\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.1.1.min.js\": \"xIGPmVtaOm+z0BqfSOMn4lOR6ciex448GIKG4eE61LsAvmGj48XcMQZtKcE/UXZe\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.1.1.min.js\": \"Dc9u1wF/0zApGIWoBbH77iWEHtdmkuYWG839Uzmv8y8yBLXebjO9ZnERsde5Ln/P\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.1.1.min.js\": \"cT9JaBz7GiRXdENrJLZNSC6eMNF3nh3fa5fTF51Svp+ukxPdwcU5kGXGPBgDCa2j\"};\n",
"\n",
" for (var i = 0; i < js_urls.length; i++) {\n",
" var url = js_urls[i];\n",
" var element = document.createElement('script');\n",
" element.onload = on_load;\n",
" element.onerror = on_error;\n",
" element.async = false;\n",
" element.src = url;\n",
" if (url in hashes) {\n",
" element.crossOrigin = \"anonymous\";\n",
" element.integrity = \"sha384-\" + hashes[url];\n",
" }\n",
" console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n",
" document.head.appendChild(element);\n",
" }\n",
" };\n",
"\n",
" function inject_raw_css(css) {\n",
" const element = document.createElement(\"style\");\n",
" element.appendChild(document.createTextNode(css));\n",
" document.body.appendChild(element);\n",
" }\n",
"\n",
" \n",
" var js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.1.1.min.js\"];\n",
" var css_urls = [];\n",
" \n",
"\n",
" var inline_js = [\n",
" function(Bokeh) {\n",
" Bokeh.set_log_level(\"info\");\n",
" },\n",
" function(Bokeh) {\n",
" \n",
" \n",
" }\n",
" ];\n",
"\n",
" function run_inline_js() {\n",
" \n",
" if (root.Bokeh !== undefined || force === true) {\n",
" \n",
" for (var i = 0; i < inline_js.length; i++) {\n",
" inline_js[i].call(root, root.Bokeh);\n",
" }\n",
" } else if (Date.now() < root._bokeh_timeout) {\n",
" setTimeout(run_inline_js, 100);\n",
" } else if (!root._bokeh_failed_load) {\n",
" console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n",
" root._bokeh_failed_load = true;\n",
" } else if (force !== true) {\n",
" var cell = $(document.getElementById(null)).parents('.cell').data().cell;\n",
" cell.output_area.append_execute_result(NB_LOAD_WARNING)\n",
" }\n",
"\n",
" }\n",
"\n",
" if (root._bokeh_is_loading === 0) {\n",
" console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n",
" run_inline_js();\n",
" } else {\n",
" load_libs(css_urls, js_urls, function() {\n",
" console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n",
" run_inline_js();\n",
" });\n",
" }\n",
"}(window));"
],
"application/vnd.bokehjs_load.v0+json": "\n(function(root) {\n function now() {\n return new Date();\n }\n\n var force = true;\n\n if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\n \n\n \n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n var NB_LOAD_WARNING = {'data': {'text/html':\n \"<div style='background-color: #fdd'>\\n\"+\n \"<p>\\n\"+\n \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n \"</p>\\n\"+\n \"<ul>\\n\"+\n \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n \"<li>use INLINE resources instead, as so:</li>\\n\"+\n \"</ul>\\n\"+\n \"<code>\\n\"+\n \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"</code>\\n\"+\n \"</div>\"}};\n\n function display_loaded() {\n var el = document.getElementById(null);\n if (el != null) {\n el.textContent = \"BokehJS is loading...\";\n }\n if (root.Bokeh !== undefined) {\n if (el != null) {\n el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(display_loaded, 100)\n }\n }\n\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) {\n if (callback != null)\n callback();\n });\n } finally {\n delete root._bokeh_onload_callbacks\n }\n console.debug(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(css_urls, js_urls, callback) {\n if (css_urls == null) css_urls = [];\n if (js_urls == null) js_urls = [];\n\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls == null || js_urls.length === 0) {\n run_callbacks();\n return null;\n }\n console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n root._bokeh_is_loading = css_urls.length + js_urls.length;\n\n function on_load() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n run_callbacks()\n }\n }\n\n function on_error() {\n console.error(\"failed to load \" + url);\n }\n\n for (var i = 0; i < css_urls.length; i++) {\n var url = css_urls[i];\n const element = document.createElement(\"link\");\n element.onload = on_load;\n element.onerror = on_error;\n element.rel = \"stylesheet\";\n element.type = \"text/css\";\n element.href = url;\n console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n document.body.appendChild(element);\n }\n\n const hashes = {\"https://cdn.bokeh.org/bokeh/release/bokeh-2.1.1.min.js\": \"kLr4fYcqcSpbuI95brIH3vnnYCquzzSxHPU6XGQCIkQRGJwhg0StNbj1eegrHs12\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.1.1.min.js\": \"xIGPmVtaOm+z0BqfSOMn4lOR6ciex448GIKG4eE61LsAvmGj48XcMQZtKcE/UXZe\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.1.1.min.js\": \"Dc9u1wF/0zApGIWoBbH77iWEHtdmkuYWG839Uzmv8y8yBLXebjO9ZnERsde5Ln/P\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.1.1.min.js\": \"cT9JaBz7GiRXdENrJLZNSC6eMNF3nh3fa5fTF51Svp+ukxPdwcU5kGXGPBgDCa2j\"};\n\n for (var i = 0; i < js_urls.length; i++) {\n var url = js_urls[i];\n var element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error;\n element.async = false;\n element.src = url;\n if (url in hashes) {\n element.crossOrigin = \"anonymous\";\n element.integrity = \"sha384-\" + hashes[url];\n }\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n };\n\n function inject_raw_css(css) {\n const element = document.createElement(\"style\");\n element.appendChild(document.createTextNode(css));\n document.body.appendChild(element);\n }\n\n \n var js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.1.1.min.js\"];\n var css_urls = [];\n \n\n var inline_js = [\n function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\n function(Bokeh) {\n \n \n }\n ];\n\n function run_inline_js() {\n \n if (root.Bokeh !== undefined || force === true) {\n \n for (var i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n } else if (force !== true) {\n var cell = $(document.getElementById(null)).parents('.cell').data().cell;\n cell.output_area.append_execute_result(NB_LOAD_WARNING)\n }\n\n }\n\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(css_urls, js_urls, function() {\n console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));"
},
"metadata": {
"tags": []
}
},
{
"output_type": "display_data",
"data": {
"text/html": [
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
" <div class=\"bk-root\" id=\"3f88f9c6-9f48-48f4-b06b-6c0868984055\" data-root-id=\"1348\"></div>\n"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "display_data",
"data": {
"application/javascript": [
"(function(root) {\n",
" function embed_document(root) {\n",
" \n",
" var docs_json = {\"28f13dce-faa7-446a-b79b-19be2c1d41a4\":{\"roots\":{\"references\":[{\"attributes\":{\"below\":[{\"id\":\"1357\"}],\"center\":[{\"id\":\"1359\"},{\"id\":\"1363\"},{\"id\":\"1392\"}],\"left\":[{\"id\":\"1360\"}],\"plot_height\":400,\"renderers\":[{\"id\":\"1381\"},{\"id\":\"1399\"},{\"id\":\"1416\"},{\"id\":\"1433\"},{\"id\":\"1450\"}],\"title\":{\"id\":\"1384\"},\"toolbar\":{\"id\":\"1371\"},\"x_range\":{\"id\":\"1349\"},\"x_scale\":{\"id\":\"1353\"},\"y_range\":{\"id\":\"1351\"},\"y_scale\":{\"id\":\"1355\"}},\"id\":\"1348\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{},\"id\":\"1355\",\"type\":\"LinearScale\"},{\"attributes\":{\"label\":{\"value\":\"Elemental\"},\"renderers\":[{\"id\":\"1381\"}]},\"id\":\"1393\",\"type\":\"LegendItem\"},{\"attributes\":{},\"id\":\"1390\",\"type\":\"Selection\"},{\"attributes\":{\"data_source\":{\"id\":\"1347\"},\"glyph\":{\"id\":\"1448\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"1449\"},\"selection_glyph\":null,\"view\":{\"id\":\"1451\"}},\"id\":\"1450\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"1391\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"items\":[{\"id\":\"1393\"},{\"id\":\"1410\"},{\"id\":\"1427\"},{\"id\":\"1444\"},{\"id\":\"1461\"}],\"location\":\"top_left\"},\"id\":\"1392\",\"type\":\"Legend\"},{\"attributes\":{\"source\":{\"id\":\"1347\"}},\"id\":\"1451\",\"type\":\"CDSView\"},{\"attributes\":{\"callback\":null,\"renderers\":[{\"id\":\"1381\"}],\"tooltips\":[[\"Ingles\",\"Elemental\"],[\"Salario\",\"@Elemental{$0,0}\"]]},\"id\":\"1394\",\"type\":\"HoverTool\"},{\"attributes\":{\"line_alpha\":0.1,\"line_color\":\"#7570b3\",\"line_width\":2,\"x\":{\"field\":\"exp\"},\"y\":{\"field\":\"Limitado\"}},\"id\":\"1398\",\"type\":\"Line\"},{\"attributes\":{},\"id\":\"1364\",\"type\":\"PanTool\"},{\"attributes\":{\"data_source\":{\"id\":\"1347\"},\"glyph\":{\"id\":\"1414\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"1415\"},\"selection_glyph\":null,\"view\":{\"id\":\"1417\"}},\"id\":\"1416\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"line_alpha\":0.1,\"line_color\":\"#e6ab02\",\"line_width\":2,\"x\":{\"field\":\"exp\"},\"y\":{\"field\":\"Nativo\"}},\"id\":\"1449\",\"type\":\"Line\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_multi\":null,\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"1364\"},{\"id\":\"1365\"},{\"id\":\"1366\"},{\"id\":\"1367\"},{\"id\":\"1368\"},{\"id\":\"1369\"},{\"id\":\"1394\"},{\"id\":\"1411\"},{\"id\":\"1428\"},{\"id\":\"1445\"},{\"id\":\"1462\"}]},\"id\":\"1371\",\"type\":\"Toolbar\"},{\"attributes\":{\"source\":{\"id\":\"1347\"}},\"id\":\"1382\",\"type\":\"CDSView\"},{\"attributes\":{\"text\":\"Salario de acuerdo al nivel de ingl\\u00e9s\"},\"id\":\"1384\",\"type\":\"Title\"},{\"attributes\":{\"data\":{\"Avanzado\":{\"__ndarray__\":\"AAAAAABq2EAAAAAAgOvhQAAAAAAA5+hAAAAAAABq6EAAAAAAABfxQAAAAAAAdfJAAAAAAGDF8UAAAAAAwHrwQA==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[8]},\"Elemental\":{\"__ndarray__\":\"AAAAAABkyUAAAAAAAIjTQAAAAAAAfNVAAAAAAABk2UAAAAAAAFjbQAAAAACAN+ZAAAAAAAAd4EAAAAAAAAXkQA==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[8]},\"Limitado\":{\"__ndarray__\":\"AAAAAABMzUAAAAAAAGrYQAAAAAAAUtxAAAAAAAAX4UAAAAAAAI7iQAAAAAAAiONAAAAAAAAX4UAAAAAAAPnlQA==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[8]},\"Nativo\":{\"__ndarray__\":\"AAAAAACBwEAAAAAAgDHnQAAAAACAQ+RAAAAAAACU8UAAAAAAAAX0QAAAAACgJvFAAAAAAAC9/0AAAAAAAHz1QA==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[8]},\"Profesional\":{\"__ndarray__\":\"AAAAAABK1UAAAAAAAB3gQAAAAAAA/+RAAAAAAADb6kAAAAAAANXrQAAAAAAAauhAAAAAAADh6UAAAAAAAGroQA==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[8]},\"exp\":[\"0-2\",\"3-4\",\"5-6\",\"7-8\",\"9-10\",\"11-14\",\"15-20\",\"20+\"],\"index\":[0,1,2,3,4,5,6,7]},\"selected\":{\"id\":\"1390\"},\"selection_policy\":{\"id\":\"1391\"}},\"id\":\"1347\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"source\":{\"id\":\"1347\"}},\"id\":\"1417\",\"type\":\"CDSView\"},{\"attributes\":{\"label\":{\"value\":\"Nativo\"},\"renderers\":[{\"id\":\"1450\"}]},\"id\":\"1461\",\"type\":\"LegendItem\"},{\"attributes\":{},\"id\":\"1368\",\"type\":\"ResetTool\"},{\"attributes\":{\"line_alpha\":0.1,\"line_color\":\"#e7298a\",\"line_width\":2,\"x\":{\"field\":\"exp\"},\"y\":{\"field\":\"Profesional\"}},\"id\":\"1415\",\"type\":\"Line\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":0.5,\"fill_color\":\"lightgrey\",\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":1.0,\"line_color\":\"black\",\"line_dash\":[4,4],\"line_width\":2,\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"1370\",\"type\":\"BoxAnnotation\"},{\"attributes\":{\"data_source\":{\"id\":\"1347\"},\"glyph\":{\"id\":\"1379\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"1380\"},\"selection_glyph\":null,\"view\":{\"id\":\"1382\"}},\"id\":\"1381\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"line_alpha\":0.1,\"line_color\":\"#d95f02\",\"line_width\":2,\"x\":{\"field\":\"exp\"},\"y\":{\"field\":\"Elemental\"}},\"id\":\"1380\",\"type\":\"Line\"},{\"attributes\":{\"label\":{\"value\":\"Profesional\"},\"renderers\":[{\"id\":\"1416\"}]},\"id\":\"1427\",\"type\":\"LegendItem\"},{\"attributes\":{\"callback\":null,\"renderers\":[{\"id\":\"1416\"}],\"tooltips\":[[\"Ingles\",\"Profesional\"],[\"Salario\",\"@Profesional{$0,0}\"]]},\"id\":\"1428\",\"type\":\"HoverTool\"},{\"attributes\":{\"format\":\"$0 a\"},\"id\":\"1465\",\"type\":\"NumeralTickFormatter\"},{\"attributes\":{},\"id\":\"1367\",\"type\":\"SaveTool\"},{\"attributes\":{\"line_color\":\"#e6ab02\",\"line_width\":2,\"x\":{\"field\":\"exp\"},\"y\":{\"field\":\"Nativo\"}},\"id\":\"1448\",\"type\":\"Line\"},{\"attributes\":{},\"id\":\"1358\",\"type\":\"CategoricalTicker\"},{\"attributes\":{\"line_color\":\"#66a61e\",\"line_width\":2,\"x\":{\"field\":\"exp\"},\"y\":{\"field\":\"Avanzado\"}},\"id\":\"1431\",\"type\":\"Line\"},{\"attributes\":{\"line_color\":\"#7570b3\",\"line_width\":2,\"x\":{\"field\":\"exp\"},\"y\":{\"field\":\"Limitado\"}},\"id\":\"1397\",\"type\":\"Line\"},{\"attributes\":{\"axis\":{\"id\":\"1360\"},\"dimension\":1,\"ticker\":null},\"id\":\"1363\",\"type\":\"Grid\"},{\"attributes\":{\"line_color\":\"#e7298a\",\"line_width\":2,\"x\":{\"field\":\"exp\"},\"y\":{\"field\":\"Profesional\"}},\"id\":\"1414\",\"type\":\"Line\"},{\"attributes\":{\"data_source\":{\"id\":\"1347\"},\"glyph\":{\"id\":\"1431\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"1432\"},\"selection_glyph\":null,\"view\":{\"id\":\"1434\"}},\"id\":\"1433\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"1351\",\"type\":\"DataRange1d\"},{\"attributes\":{\"overlay\":{\"id\":\"1370\"}},\"id\":\"1366\",\"type\":\"BoxZoomTool\"},{\"attributes\":{\"source\":{\"id\":\"1347\"}},\"id\":\"1400\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"1361\",\"type\":\"BasicTicker\"},{\"attributes\":{\"axis\":{\"id\":\"1357\"},\"ticker\":null},\"id\":\"1359\",\"type\":\"Grid\"},{\"attributes\":{\"line_color\":\"#d95f02\",\"line_width\":2,\"x\":{\"field\":\"exp\"},\"y\":{\"field\":\"Elemental\"}},\"id\":\"1379\",\"type\":\"Line\"},{\"attributes\":{\"source\":{\"id\":\"1347\"}},\"id\":\"1434\",\"type\":\"CDSView\"},{\"attributes\":{\"axis_label\":\"Experiencia (a\\u00f1os)\",\"formatter\":{\"id\":\"1387\"},\"ticker\":{\"id\":\"1358\"}},\"id\":\"1357\",\"type\":\"CategoricalAxis\"},{\"attributes\":{},\"id\":\"1369\",\"type\":\"HelpTool\"},{\"attributes\":{\"factors\":[\"0-2\",\"3-4\",\"5-6\",\"7-8\",\"9-10\",\"11-14\",\"15-20\",\"20+\"]},\"id\":\"1349\",\"type\":\"FactorRange\"},{\"attributes\":{\"line_alpha\":0.1,\"line_color\":\"#66a61e\",\"line_width\":2,\"x\":{\"field\":\"exp\"},\"y\":{\"field\":\"Avanzado\"}},\"id\":\"1432\",\"type\":\"Line\"},{\"attributes\":{\"data_source\":{\"id\":\"1347\"},\"glyph\":{\"id\":\"1397\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"1398\"},\"selection_glyph\":null,\"view\":{\"id\":\"1400\"}},\"id\":\"1399\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"1387\",\"type\":\"CategoricalTickFormatter\"},{\"attributes\":{\"label\":{\"value\":\"Avanzado\"},\"renderers\":[{\"id\":\"1433\"}]},\"id\":\"1444\",\"type\":\"LegendItem\"},{\"attributes\":{\"axis_label\":\"Salario\",\"formatter\":{\"id\":\"1465\"},\"ticker\":{\"id\":\"1361\"}},\"id\":\"1360\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"1365\",\"type\":\"WheelZoomTool\"},{\"attributes\":{\"callback\":null,\"renderers\":[{\"id\":\"1433\"}],\"tooltips\":[[\"Ingles\",\"Avanzado\"],[\"Salario\",\"@Avanzado{$0,0}\"]]},\"id\":\"1445\",\"type\":\"HoverTool\"},{\"attributes\":{\"label\":{\"value\":\"Limitado\"},\"renderers\":[{\"id\":\"1399\"}]},\"id\":\"1410\",\"type\":\"LegendItem\"},{\"attributes\":{},\"id\":\"1353\",\"type\":\"CategoricalScale\"},{\"attributes\":{\"callback\":null,\"renderers\":[{\"id\":\"1399\"}],\"tooltips\":[[\"Ingles\",\"Limitado\"],[\"Salario\",\"@Limitado{$0,0}\"]]},\"id\":\"1411\",\"type\":\"HoverTool\"},{\"attributes\":{\"callback\":null,\"renderers\":[{\"id\":\"1450\"}],\"tooltips\":[[\"Ingles\",\"Nativo\"],[\"Salario\",\"@Nativo{$0,0}\"]]},\"id\":\"1462\",\"type\":\"HoverTool\"}],\"root_ids\":[\"1348\"]},\"title\":\"Bokeh Application\",\"version\":\"2.1.1\"}};\n",
" var render_items = [{\"docid\":\"28f13dce-faa7-446a-b79b-19be2c1d41a4\",\"root_ids\":[\"1348\"],\"roots\":{\"1348\":\"3f88f9c6-9f48-48f4-b06b-6c0868984055\"}}];\n",
" root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n",
"\n",
" }\n",
" if (root.Bokeh !== undefined) {\n",
" embed_document(root);\n",
" } else {\n",
" var attempts = 0;\n",
" var timer = setInterval(function(root) {\n",
" if (root.Bokeh !== undefined) {\n",
" clearInterval(timer);\n",
" embed_document(root);\n",
" } else {\n",
" attempts++;\n",
" if (attempts > 100) {\n",
" clearInterval(timer);\n",
" console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n",
" }\n",
" }\n",
" }, 10, root)\n",
" }\n",
"})(window);"
],
"application/vnd.bokehjs_exec.v0+json": ""
},
"metadata": {
"tags": [],
"application/vnd.bokehjs_exec.v0+json": {
"id": "1348"
}
}
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "C9lSej-w1pYz"
},
"source": [
"## Agrupación por ciudad y país"
]
},
{
"cell_type": "code",
"metadata": {
"id": "wmcD6tCg1pYz",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 482
},
"outputId": "b0e3e718-8fbe-4ce0-c705-ca370a867c62"
},
"source": [
"# Solo tomamos en cuenta a las personas con perfil de empleado (no freelancers, directivos ni emprendedores)\n",
"# Incluimos la experiencia como variable observada para obtener el promedio de experiencia por ciudad\n",
"cities = df[(df[\"profile\"] == \"godin\")].groupby(\"city\")['salarymx', 'experience'].agg(['count', 'median', 'mean', 'std'])\n",
"cities = cities.reset_index()\n",
"\n",
"# El group by de múltiples columnas observadas con múltiples funciones agregadas nos genera que los nombre son tuplas\n",
"# así que hacemos este map para renombrar las columnas.\n",
"cities.columns = cities.columns.map('_'.join)\n",
"\n",
"cities = cities[(cities[\"salarymx_count\"]> 10)]\n",
"cities = cities[(cities[\"salarymx_median\"]> 0)]\n",
"cities = cities.sort_values(by=['salarymx_median'], ascending=False)\n",
"src = ColumnDataSource(cities)\n",
"columns = [\n",
" TableColumn(field=\"city_\", title=\"Ciudad\"),\n",
" TableColumn(field=\"salarymx_count\", title=\"n\"),\n",
" TableColumn(field=\"salarymx_median\", title=\"Mediana\", formatter=NumberFormatter(format='$0,0')),\n",
" TableColumn(field=\"salarymx_mean\", title=\"Media\", formatter=NumberFormatter(format='$0,0')),\n",
" TableColumn(field=\"salarymx_std\", title=\"Des std\", formatter=NumberFormatter(format='$0,0')),\n",
" TableColumn(field=\"experience_mean\", title=\"Experiencia promedio\", formatter=NumberFormatter(format='0')),\n",
" ]\n",
"table = DataTable(source=src,columns=columns,index_position=None, width=400)\n",
"show(table)"
],
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"text": [
"/usr/local/lib/python3.7/dist-packages/ipykernel_launcher.py:3: FutureWarning: Indexing with multiple keys (implicitly converted to a tuple of keys) will be deprecated, use a list instead.\n",
" This is separate from the ipykernel package so we can avoid doing imports until\n"
],
"name": "stderr"
},
{
"output_type": "display_data",
"data": {
"application/javascript": [
"\n",
"(function(root) {\n",
" function now() {\n",
" return new Date();\n",
" }\n",
"\n",
" var force = true;\n",
"\n",
" if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n",
" root._bokeh_onload_callbacks = [];\n",
" root._bokeh_is_loading = undefined;\n",
" }\n",
"\n",
" var JS_MIME_TYPE = 'application/javascript';\n",
" var HTML_MIME_TYPE = 'text/html';\n",
" var EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n",
" var CLASS_NAME = 'output_bokeh rendered_html';\n",
"\n",
" /**\n",
" * Render data to the DOM node\n",
" */\n",
" function render(props, node) {\n",
" var script = document.createElement(\"script\");\n",
" node.appendChild(script);\n",
" }\n",
"\n",
" /**\n",
" * Handle when an output is cleared or removed\n",
" */\n",
" function handleClearOutput(event, handle) {\n",
" var cell = handle.cell;\n",
"\n",
" var id = cell.output_area._bokeh_element_id;\n",
" var server_id = cell.output_area._bokeh_server_id;\n",
" // Clean up Bokeh references\n",
" if (id != null && id in Bokeh.index) {\n",
" Bokeh.index[id].model.document.clear();\n",
" delete Bokeh.index[id];\n",
" }\n",
"\n",
" if (server_id !== undefined) {\n",
" // Clean up Bokeh references\n",
" var cmd = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n",
" cell.notebook.kernel.execute(cmd, {\n",
" iopub: {\n",
" output: function(msg) {\n",
" var id = msg.content.text.trim();\n",
" if (id in Bokeh.index) {\n",
" Bokeh.index[id].model.document.clear();\n",
" delete Bokeh.index[id];\n",
" }\n",
" }\n",
" }\n",
" });\n",
" // Destroy server and session\n",
" var cmd = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n",
" cell.notebook.kernel.execute(cmd);\n",
" }\n",
" }\n",
"\n",
" /**\n",
" * Handle when a new output is added\n",
" */\n",
" function handleAddOutput(event, handle) {\n",
" var output_area = handle.output_area;\n",
" var output = handle.output;\n",
"\n",
" // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n",
" if ((output.output_type != \"display_data\") || (!output.data.hasOwnProperty(EXEC_MIME_TYPE))) {\n",
" return\n",
" }\n",
"\n",
" var toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n",
"\n",
" if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n",
" toinsert[toinsert.length - 1].firstChild.textContent = output.data[JS_MIME_TYPE];\n",
" // store reference to embed id on output_area\n",
" output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n",
" }\n",
" if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n",
" var bk_div = document.createElement(\"div\");\n",
" bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n",
" var script_attrs = bk_div.children[0].attributes;\n",
" for (var i = 0; i < script_attrs.length; i++) {\n",
" toinsert[toinsert.length - 1].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n",
" toinsert[toinsert.length - 1].firstChild.textContent = bk_div.children[0].textContent\n",
" }\n",
" // store reference to server id on output_area\n",
" output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n",
" }\n",
" }\n",
"\n",
" function register_renderer(events, OutputArea) {\n",
"\n",
" function append_mime(data, metadata, element) {\n",
" // create a DOM node to render to\n",
" var toinsert = this.create_output_subarea(\n",
" metadata,\n",
" CLASS_NAME,\n",
" EXEC_MIME_TYPE\n",
" );\n",
" this.keyboard_manager.register_events(toinsert);\n",
" // Render to node\n",
" var props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n",
" render(props, toinsert[toinsert.length - 1]);\n",
" element.append(toinsert);\n",
" return toinsert\n",
" }\n",
"\n",
" /* Handle when an output is cleared or removed */\n",
" events.on('clear_output.CodeCell', handleClearOutput);\n",
" events.on('delete.Cell', handleClearOutput);\n",
"\n",
" /* Handle when a new output is added */\n",
" events.on('output_added.OutputArea', handleAddOutput);\n",
"\n",
" /**\n",
" * Register the mime type and append_mime function with output_area\n",
" */\n",
" OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n",
" /* Is output safe? */\n",
" safe: true,\n",
" /* Index of renderer in `output_area.display_order` */\n",
" index: 0\n",
" });\n",
" }\n",
"\n",
" // register the mime type if in Jupyter Notebook environment and previously unregistered\n",
" if (root.Jupyter !== undefined) {\n",
" var events = require('base/js/events');\n",
" var OutputArea = require('notebook/js/outputarea').OutputArea;\n",
"\n",
" if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n",
" register_renderer(events, OutputArea);\n",
" }\n",
" }\n",
"\n",
" \n",
" if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n",
" root._bokeh_timeout = Date.now() + 5000;\n",
" root._bokeh_failed_load = false;\n",
" }\n",
"\n",
" var NB_LOAD_WARNING = {'data': {'text/html':\n",
" \"<div style='background-color: #fdd'>\\n\"+\n",
" \"<p>\\n\"+\n",
" \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n",
" \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n",
" \"</p>\\n\"+\n",
" \"<ul>\\n\"+\n",
" \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n",
" \"<li>use INLINE resources instead, as so:</li>\\n\"+\n",
" \"</ul>\\n\"+\n",
" \"<code>\\n\"+\n",
" \"from bokeh.resources import INLINE\\n\"+\n",
" \"output_notebook(resources=INLINE)\\n\"+\n",
" \"</code>\\n\"+\n",
" \"</div>\"}};\n",
"\n",
" function display_loaded() {\n",
" var el = document.getElementById(null);\n",
" if (el != null) {\n",
" el.textContent = \"BokehJS is loading...\";\n",
" }\n",
" if (root.Bokeh !== undefined) {\n",
" if (el != null) {\n",
" el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n",
" }\n",
" } else if (Date.now() < root._bokeh_timeout) {\n",
" setTimeout(display_loaded, 100)\n",
" }\n",
" }\n",
"\n",
"\n",
" function run_callbacks() {\n",
" try {\n",
" root._bokeh_onload_callbacks.forEach(function(callback) {\n",
" if (callback != null)\n",
" callback();\n",
" });\n",
" } finally {\n",
" delete root._bokeh_onload_callbacks\n",
" }\n",
" console.debug(\"Bokeh: all callbacks have finished\");\n",
" }\n",
"\n",
" function load_libs(css_urls, js_urls, callback) {\n",
" if (css_urls == null) css_urls = [];\n",
" if (js_urls == null) js_urls = [];\n",
"\n",
" root._bokeh_onload_callbacks.push(callback);\n",
" if (root._bokeh_is_loading > 0) {\n",
" console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n",
" return null;\n",
" }\n",
" if (js_urls == null || js_urls.length === 0) {\n",
" run_callbacks();\n",
" return null;\n",
" }\n",
" console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n",
" root._bokeh_is_loading = css_urls.length + js_urls.length;\n",
"\n",
" function on_load() {\n",
" root._bokeh_is_loading--;\n",
" if (root._bokeh_is_loading === 0) {\n",
" console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n",
" run_callbacks()\n",
" }\n",
" }\n",
"\n",
" function on_error() {\n",
" console.error(\"failed to load \" + url);\n",
" }\n",
"\n",
" for (var i = 0; i < css_urls.length; i++) {\n",
" var url = css_urls[i];\n",
" const element = document.createElement(\"link\");\n",
" element.onload = on_load;\n",
" element.onerror = on_error;\n",
" element.rel = \"stylesheet\";\n",
" element.type = \"text/css\";\n",
" element.href = url;\n",
" console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n",
" document.body.appendChild(element);\n",
" }\n",
"\n",
" const hashes = {\"https://cdn.bokeh.org/bokeh/release/bokeh-2.1.1.min.js\": \"kLr4fYcqcSpbuI95brIH3vnnYCquzzSxHPU6XGQCIkQRGJwhg0StNbj1eegrHs12\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.1.1.min.js\": \"xIGPmVtaOm+z0BqfSOMn4lOR6ciex448GIKG4eE61LsAvmGj48XcMQZtKcE/UXZe\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.1.1.min.js\": \"Dc9u1wF/0zApGIWoBbH77iWEHtdmkuYWG839Uzmv8y8yBLXebjO9ZnERsde5Ln/P\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.1.1.min.js\": \"cT9JaBz7GiRXdENrJLZNSC6eMNF3nh3fa5fTF51Svp+ukxPdwcU5kGXGPBgDCa2j\"};\n",
"\n",
" for (var i = 0; i < js_urls.length; i++) {\n",
" var url = js_urls[i];\n",
" var element = document.createElement('script');\n",
" element.onload = on_load;\n",
" element.onerror = on_error;\n",
" element.async = false;\n",
" element.src = url;\n",
" if (url in hashes) {\n",
" element.crossOrigin = \"anonymous\";\n",
" element.integrity = \"sha384-\" + hashes[url];\n",
" }\n",
" console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n",
" document.head.appendChild(element);\n",
" }\n",
" };\n",
"\n",
" function inject_raw_css(css) {\n",
" const element = document.createElement(\"style\");\n",
" element.appendChild(document.createTextNode(css));\n",
" document.body.appendChild(element);\n",
" }\n",
"\n",
" \n",
" var js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.1.1.min.js\"];\n",
" var css_urls = [];\n",
" \n",
"\n",
" var inline_js = [\n",
" function(Bokeh) {\n",
" Bokeh.set_log_level(\"info\");\n",
" },\n",
" function(Bokeh) {\n",
" \n",
" \n",
" }\n",
" ];\n",
"\n",
" function run_inline_js() {\n",
" \n",
" if (root.Bokeh !== undefined || force === true) {\n",
" \n",
" for (var i = 0; i < inline_js.length; i++) {\n",
" inline_js[i].call(root, root.Bokeh);\n",
" }\n",
" } else if (Date.now() < root._bokeh_timeout) {\n",
" setTimeout(run_inline_js, 100);\n",
" } else if (!root._bokeh_failed_load) {\n",
" console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n",
" root._bokeh_failed_load = true;\n",
" } else if (force !== true) {\n",
" var cell = $(document.getElementById(null)).parents('.cell').data().cell;\n",
" cell.output_area.append_execute_result(NB_LOAD_WARNING)\n",
" }\n",
"\n",
" }\n",
"\n",
" if (root._bokeh_is_loading === 0) {\n",
" console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n",
" run_inline_js();\n",
" } else {\n",
" load_libs(css_urls, js_urls, function() {\n",
" console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n",
" run_inline_js();\n",
" });\n",
" }\n",
"}(window));"
],
"application/vnd.bokehjs_load.v0+json": "\n(function(root) {\n function now() {\n return new Date();\n }\n\n var force = true;\n\n if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\n \n\n \n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n var NB_LOAD_WARNING = {'data': {'text/html':\n \"<div style='background-color: #fdd'>\\n\"+\n \"<p>\\n\"+\n \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n \"</p>\\n\"+\n \"<ul>\\n\"+\n \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n \"<li>use INLINE resources instead, as so:</li>\\n\"+\n \"</ul>\\n\"+\n \"<code>\\n\"+\n \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"</code>\\n\"+\n \"</div>\"}};\n\n function display_loaded() {\n var el = document.getElementById(null);\n if (el != null) {\n el.textContent = \"BokehJS is loading...\";\n }\n if (root.Bokeh !== undefined) {\n if (el != null) {\n el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(display_loaded, 100)\n }\n }\n\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) {\n if (callback != null)\n callback();\n });\n } finally {\n delete root._bokeh_onload_callbacks\n }\n console.debug(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(css_urls, js_urls, callback) {\n if (css_urls == null) css_urls = [];\n if (js_urls == null) js_urls = [];\n\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls == null || js_urls.length === 0) {\n run_callbacks();\n return null;\n }\n console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n root._bokeh_is_loading = css_urls.length + js_urls.length;\n\n function on_load() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n run_callbacks()\n }\n }\n\n function on_error() {\n console.error(\"failed to load \" + url);\n }\n\n for (var i = 0; i < css_urls.length; i++) {\n var url = css_urls[i];\n const element = document.createElement(\"link\");\n element.onload = on_load;\n element.onerror = on_error;\n element.rel = \"stylesheet\";\n element.type = \"text/css\";\n element.href = url;\n console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n document.body.appendChild(element);\n }\n\n const hashes = {\"https://cdn.bokeh.org/bokeh/release/bokeh-2.1.1.min.js\": \"kLr4fYcqcSpbuI95brIH3vnnYCquzzSxHPU6XGQCIkQRGJwhg0StNbj1eegrHs12\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.1.1.min.js\": \"xIGPmVtaOm+z0BqfSOMn4lOR6ciex448GIKG4eE61LsAvmGj48XcMQZtKcE/UXZe\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.1.1.min.js\": \"Dc9u1wF/0zApGIWoBbH77iWEHtdmkuYWG839Uzmv8y8yBLXebjO9ZnERsde5Ln/P\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.1.1.min.js\": \"cT9JaBz7GiRXdENrJLZNSC6eMNF3nh3fa5fTF51Svp+ukxPdwcU5kGXGPBgDCa2j\"};\n\n for (var i = 0; i < js_urls.length; i++) {\n var url = js_urls[i];\n var element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error;\n element.async = false;\n element.src = url;\n if (url in hashes) {\n element.crossOrigin = \"anonymous\";\n element.integrity = \"sha384-\" + hashes[url];\n }\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n };\n\n function inject_raw_css(css) {\n const element = document.createElement(\"style\");\n element.appendChild(document.createTextNode(css));\n document.body.appendChild(element);\n }\n\n \n var js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.1.1.min.js\"];\n var css_urls = [];\n \n\n var inline_js = [\n function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\n function(Bokeh) {\n \n \n }\n ];\n\n function run_inline_js() {\n \n if (root.Bokeh !== undefined || force === true) {\n \n for (var i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n } else if (force !== true) {\n var cell = $(document.getElementById(null)).parents('.cell').data().cell;\n cell.output_area.append_execute_result(NB_LOAD_WARNING)\n }\n\n }\n\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(css_urls, js_urls, function() {\n console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));"
},
"metadata": {
"tags": []
}
},
{
"output_type": "display_data",
"data": {
"text/html": [
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
" <div class=\"bk-root\" id=\"f73b25e5-a7e1-4407-afc9-03831baedce4\" data-root-id=\"1562\"></div>\n"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "display_data",
"data": {
"application/javascript": [
"(function(root) {\n",
" function embed_document(root) {\n",
" \n",
" var docs_json = {\"282b93a8-64cd-43d5-b90d-1b13cd8f03e0\":{\"roots\":{\"references\":[{\"attributes\":{\"columns\":[{\"id\":\"1548\"},{\"id\":\"1549\"},{\"id\":\"1551\"},{\"id\":\"1554\"},{\"id\":\"1557\"},{\"id\":\"1560\"}],\"index_position\":null,\"source\":{\"id\":\"1547\"},\"view\":{\"id\":\"1563\"},\"width\":400},\"id\":\"1562\",\"type\":\"DataTable\"},{\"attributes\":{\"format\":\"$0,0\"},\"id\":\"1550\",\"type\":\"NumberFormatter\"},{\"attributes\":{},\"id\":\"1602\",\"type\":\"StringEditor\"},{\"attributes\":{},\"id\":\"1603\",\"type\":\"StringEditor\"},{\"attributes\":{\"format\":\"0\"},\"id\":\"1559\",\"type\":\"NumberFormatter\"},{\"attributes\":{},\"id\":\"1599\",\"type\":\"StringEditor\"},{\"attributes\":{\"editor\":{\"id\":\"1601\"},\"field\":\"salarymx_count\",\"formatter\":{\"id\":\"1600\"},\"title\":\"n\"},\"id\":\"1549\",\"type\":\"TableColumn\"},{\"attributes\":{\"editor\":{\"id\":\"1605\"},\"field\":\"experience_mean\",\"formatter\":{\"id\":\"1559\"},\"title\":\"Experiencia promedio\"},\"id\":\"1560\",\"type\":\"TableColumn\"},{\"attributes\":{\"editor\":{\"id\":\"1603\"},\"field\":\"salarymx_mean\",\"formatter\":{\"id\":\"1553\"},\"title\":\"Media\"},\"id\":\"1554\",\"type\":\"TableColumn\"},{\"attributes\":{\"editor\":{\"id\":\"1599\"},\"field\":\"city_\",\"formatter\":{\"id\":\"1598\"},\"title\":\"Ciudad\"},\"id\":\"1548\",\"type\":\"TableColumn\"},{\"attributes\":{},\"id\":\"1600\",\"type\":\"StringFormatter\"},{\"attributes\":{\"editor\":{\"id\":\"1604\"},\"field\":\"salarymx_std\",\"formatter\":{\"id\":\"1556\"},\"title\":\"Des std\"},\"id\":\"1557\",\"type\":\"TableColumn\"},{\"attributes\":{},\"id\":\"1596\",\"type\":\"Selection\"},{\"attributes\":{},\"id\":\"1601\",\"type\":\"StringEditor\"},{\"attributes\":{\"editor\":{\"id\":\"1602\"},\"field\":\"salarymx_median\",\"formatter\":{\"id\":\"1550\"},\"title\":\"Mediana\"},\"id\":\"1551\",\"type\":\"TableColumn\"},{\"attributes\":{\"source\":{\"id\":\"1547\"}},\"id\":\"1563\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"1597\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"format\":\"$0,0\"},\"id\":\"1556\",\"type\":\"NumberFormatter\"},{\"attributes\":{},\"id\":\"1605\",\"type\":\"StringEditor\"},{\"attributes\":{\"format\":\"$0,0\"},\"id\":\"1553\",\"type\":\"NumberFormatter\"},{\"attributes\":{\"data\":{\"city_\":[\"Hermosillo\",\"Guadalajara\",\"Aguascalientes\",\"Chihuahua\",\"Tijuana\",\"Cuernavaca\",\"Quer\\u00e9taro\",\"Le\\u00f3n\",\"Monterrey\",\"CDMX\",\"Colima\",\"Estado de M\\u00e9xico\",\"Puebla\",\"Culiac\\u00e1n\",\"San Luis Potos\\u00ed\"],\"experience_count\":[25,197,16,14,24,12,51,19,56,452,16,35,21,12,34],\"experience_mean\":{\"__ndarray__\":\"ZmZmZmZmJED8Jno6t9cgQAAAAAAAYCZAAAAAAAAAHECrqqqqqiodQAAAAAAAACNA3dzc3NzcIkAAAAAAAAAgQLdt27Zt2yFAvmzQ5MuGIkAAAAAAAEAXQLD4iq/4ih9Anud5nud5IkBVVVVVVVUoQKalpaWlpSJA\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[15]},\"experience_median\":{\"__ndarray__\":\"AAAAAAAAIkAAAAAAAAAcQAAAAAAAACJAAAAAAAAAGkAAAAAAAAAcQAAAAAAAACBAAAAAAAAAIkAAAAAAAAAcQAAAAAAAABxAAAAAAAAAHEAAAAAAAAASQAAAAAAAABRAAAAAAAAAIEAAAAAAAAAmQAAAAAAAACBA\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[15]},\"experience_std\":{\"__ndarray__\":\"5chopF53F0AJxJnH1uEWQHg9tW1mDx9A4l34wvvtDED4mbVLFaIRQN0UPgB2jxpA9WtAyXQpGUBCDMSGL0gRQPQnXYcxFhxAyvjHJ35+G0CMQqCwdewUQCaDN0jlYx1AFwyWXXcMFUAnv+xDW3gYQJnhQQCbYRpA\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[15]},\"index\":[48,44,2,16,110,32,90,55,70,7,26,41,85,34,99],\"salarymx_count\":[25,197,16,14,24,12,51,19,56,452,16,35,21,12,34],\"salarymx_mean\":{\"__ndarray__\":\"MzMzM+MC8UCMhNLG+wXsQAAAAABwDO9At23bti3960BVVVVV1dXmQFVVVVWV3OhAVVVVVVXR5kCU11Bew4zhQAAAAAAcXOVAwdsPCUwV50AAAAAAoIvlQJIkSZIk1+FAGIZhGKYm50AAAAAA4BzcQC0tLS3t9txA\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[15]},\"salarymx_median\":{\"__ndarray__\":\"AAAAAABY60AAAAAAANvqQAAAAAAA4elAAAAAAADt50AAAAAAAPPmQAAAAAAAfOVAAAAAAAD/5EAAAAAAgMbjQAAAAACAxuNAAAAAAECn40AAAAAAgNLhQAAAAAAAF+FAAAAAAAAd4EAAAAAAQCXYQAAAAAAAfNVA\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[15]},\"salarymx_std\":{\"__ndarray__\":\"C7cvvEhB7EC9OVRP/2rcQPpdD1552ORAvJx+vfc24EC7uUL/KsjTQA+yZlTZFt9Al61EZw0p20DD0T6oVmXSQHm1ZYH+otJAviEpxH6i3UByIh/XefLeQHhIKvNZM9VAhOKulFTD4kDsn7qZzOTOQFyaByj82dNA\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[15]}},\"selected\":{\"id\":\"1596\"},\"selection_policy\":{\"id\":\"1597\"}},\"id\":\"1547\",\"type\":\"ColumnDataSource\"},{\"attributes\":{},\"id\":\"1604\",\"type\":\"StringEditor\"},{\"attributes\":{},\"id\":\"1598\",\"type\":\"StringFormatter\"}],\"root_ids\":[\"1562\"]},\"title\":\"Bokeh Application\",\"version\":\"2.1.1\"}};\n",
" var render_items = [{\"docid\":\"282b93a8-64cd-43d5-b90d-1b13cd8f03e0\",\"root_ids\":[\"1562\"],\"roots\":{\"1562\":\"f73b25e5-a7e1-4407-afc9-03831baedce4\"}}];\n",
" root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n",
"\n",
" }\n",
" if (root.Bokeh !== undefined) {\n",
" embed_document(root);\n",
" } else {\n",
" var attempts = 0;\n",
" var timer = setInterval(function(root) {\n",
" if (root.Bokeh !== undefined) {\n",
" clearInterval(timer);\n",
" embed_document(root);\n",
" } else {\n",
" attempts++;\n",
" if (attempts > 100) {\n",
" clearInterval(timer);\n",
" console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n",
" }\n",
" }\n",
" }, 10, root)\n",
" }\n",
"})(window);"
],
"application/vnd.bokehjs_exec.v0+json": ""
},
"metadata": {
"tags": [],
"application/vnd.bokehjs_exec.v0+json": {
"id": "1562"
}
}
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "Q-S-gaQLQgFY"
},
"source": [
"cities.to_csv('table_cities.csv')"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "szQiS_va1pY0"
},
"source": [
"Hagamos el breakdown por país. Para ello nos basamos en la columna salaryusd."
]
},
{
"cell_type": "code",
"metadata": {
"id": "yxqWBmuL1pY0",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 373
},
"outputId": "23e4b941-1b92-40a1-b131-6a48a5dadba7"
},
"source": [
"# Volvemos a leer del csv para incluir datos de otros países\n",
"df2 = pd.read_csv(\"https://raw.githubusercontent.com/softwareguru/salarios-notebook/main/answers-2021.csv\", index_col=0)\n",
"df2['salaryusd'] = np.where((df2.salaryusd == 0),round(df2.salarymx/19,0).astype(int), df2.salaryusd)\n",
"countries = df2.groupby(\"country\")[\"salaryusd\"].agg(['count', 'median', 'mean', 'std'])\n",
"countries = countries.reset_index()\n",
"countries = countries.sort_values(by=['median'], ascending=False)\n",
"countries.head(30)"
],
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>country</th>\n",
" <th>count</th>\n",
" <th>median</th>\n",
" <th>mean</th>\n",
" <th>std</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>Estados Unidos</td>\n",
" <td>18</td>\n",
" <td>11116.5</td>\n",
" <td>11411.111111</td>\n",
" <td>6093.012178</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>Canada</td>\n",
" <td>3</td>\n",
" <td>9000.0</td>\n",
" <td>10500.000000</td>\n",
" <td>3968.626967</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>Ecuador</td>\n",
" <td>5</td>\n",
" <td>2240.0</td>\n",
" <td>1902.000000</td>\n",
" <td>840.606924</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>España</td>\n",
" <td>2</td>\n",
" <td>2150.0</td>\n",
" <td>2150.000000</td>\n",
" <td>212.132034</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>México</td>\n",
" <td>1516</td>\n",
" <td>2105.0</td>\n",
" <td>2493.652375</td>\n",
" <td>1814.844551</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>Chile</td>\n",
" <td>18</td>\n",
" <td>2034.0</td>\n",
" <td>2386.444444</td>\n",
" <td>2149.595837</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>Otro</td>\n",
" <td>9</td>\n",
" <td>2000.0</td>\n",
" <td>5265.444444</td>\n",
" <td>7872.356336</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>Guatemala</td>\n",
" <td>2</td>\n",
" <td>1912.5</td>\n",
" <td>1912.500000</td>\n",
" <td>159.099026</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>Perú</td>\n",
" <td>12</td>\n",
" <td>1733.0</td>\n",
" <td>1881.750000</td>\n",
" <td>1121.787707</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>Colombia</td>\n",
" <td>13</td>\n",
" <td>1000.0</td>\n",
" <td>1233.615385</td>\n",
" <td>658.997539</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Argentina</td>\n",
" <td>7</td>\n",
" <td>615.0</td>\n",
" <td>765.142857</td>\n",
" <td>660.979180</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" country count median mean std\n",
"6 Estados Unidos 18 11116.5 11411.111111 6093.012178\n",
"1 Canada 3 9000.0 10500.000000 3968.626967\n",
"4 Ecuador 5 2240.0 1902.000000 840.606924\n",
"5 España 2 2150.0 2150.000000 212.132034\n",
"8 México 1516 2105.0 2493.652375 1814.844551\n",
"2 Chile 18 2034.0 2386.444444 2149.595837\n",
"9 Otro 9 2000.0 5265.444444 7872.356336\n",
"7 Guatemala 2 1912.5 1912.500000 159.099026\n",
"10 Perú 12 1733.0 1881.750000 1121.787707\n",
"3 Colombia 13 1000.0 1233.615385 658.997539\n",
"0 Argentina 7 615.0 765.142857 660.979180"
]
},
"metadata": {
"tags": []
},
"execution_count": 20
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "JcKM8e5F1pY1"
},
"source": [
"## Lenguajes\n",
"\n",
"El dilema con los lenguajes es que cada participante puede escoger varios lenguajes (máximo 3) que utiliza. Así que no podemos tener una única variable categórica para lenguaje, sino que tenemos una variable booleana (Y/N) por cada una de las opciones de lenguaje. Si tuvieramos una única variable, simplemente podríamos hacer un groupby y listo, pero al no tenerla, tenemos que \"armar\" nuestro dataframe.\n",
"\n",
"Vamos a generar una lista donde cada elemento es a su vez una lista con la info de cada lenguaje (nombre del lenguaje, número de observaciones y salario medio). A partir de esa lista de listas generamos un dataframe y continuamos como de costumbre."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "mZTY1--UHAxv"
},
"source": [
"Tenemos los catálogos (de lenguajes, certificaciones, actividades, etc) en archivos csv que están en un repositorio en GitHub, así que definimos una función que nos regrese un objeto para leer dichos archivos. Esto es nada más para no estar copiando y pegando el mismo código."
]
},
{
"cell_type": "code",
"metadata": {
"id": "daDDJD4d1pY1"
},
"source": [
"# Esta función recibe un url con un archivo csv y regresa un objeto csv.DictReader que facilita leer linea por línea en base al nombre de cada columna.\n",
"def get_remote_csv_reader(url):\n",
" import csv, urllib.request\n",
" response = urllib.request.urlopen(url)\n",
" lines = [l.decode('utf-8') for l in response.readlines()]\n",
" reader = csv.DictReader(lines)\n",
" return reader\n"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 758
},
"id": "IKrj16ebGqEC",
"outputId": "f7fc12fb-1a61-4f18-d6b0-c3e241fd1727"
},
"source": [
"# Inicializamos nuestra lista maestra\n",
"item_list = []\n",
"url = 'https://raw.githubusercontent.com/softwareguru/salarios-notebook/main/lang_options.csv'\n",
"reader = get_remote_csv_reader(url)\n",
"\n",
"for row in reader:\n",
" item_key = \"lang_\"+row['key']\n",
" # Creamos una lista con el nombre del lenguaje, su num. de observaciones y salario medio, y agregamos dicha lista a nuestra lista maestra.\n",
" item_list.append([row['name'], df[(df[item_key]==\"Y\")][\"salarymx\"].count(), df[(df[item_key]==\"Y\")][\"salarymx\"].median(), df[(df[item_key]==\"Y\")][\"salarymx\"].mean(), df[(df[item_key]==\"Y\")][\"salarymx\"].std(), df[(df[item_key]==\"Y\")][\"experience\"].mean()])\n",
"\n",
"# Una vez que tenemos la lista maestra completa, creamos un dataframe indicando el nombre de las columnas.\n",
"item_df = pd.DataFrame(item_list, columns = ['lenguaje', 'n', 'mediana','media', 'std', 'exp'])\n",
"# Agregamos una columna de popularidad que se calcule en base a un valor amortiguado del número de observaciones. \n",
"item_df['popularidad'] = round(np.sqrt(langdf['n']/2)*2)\n",
"item_df.sort_values(by=['mediana'], ascending=False).head(40)"
],
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>lenguaje</th>\n",
" <th>n</th>\n",
" <th>mediana</th>\n",
" <th>media</th>\n",
" <th>std</th>\n",
" <th>exp</th>\n",
" <th>popularidad</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>20</th>\n",
" <td>Rust</td>\n",
" <td>4</td>\n",
" <td>73000.0</td>\n",
" <td>102988.750000</td>\n",
" <td>95819.329154</td>\n",
" <td>10.250000</td>\n",
" <td>3.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>Elixir</td>\n",
" <td>14</td>\n",
" <td>72500.0</td>\n",
" <td>71500.000000</td>\n",
" <td>27402.273909</td>\n",
" <td>7.785714</td>\n",
" <td>5.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>13</th>\n",
" <td>Objective C</td>\n",
" <td>4</td>\n",
" <td>66250.0</td>\n",
" <td>58225.000000</td>\n",
" <td>25042.680235</td>\n",
" <td>6.750000</td>\n",
" <td>3.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>19</th>\n",
" <td>Ruby</td>\n",
" <td>53</td>\n",
" <td>60000.0</td>\n",
" <td>71046.075472</td>\n",
" <td>40928.739867</td>\n",
" <td>7.867925</td>\n",
" <td>10.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>Go</td>\n",
" <td>39</td>\n",
" <td>55000.0</td>\n",
" <td>65012.820513</td>\n",
" <td>37490.435127</td>\n",
" <td>7.743590</td>\n",
" <td>9.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>14</th>\n",
" <td>Perl</td>\n",
" <td>2</td>\n",
" <td>53000.0</td>\n",
" <td>53000.000000</td>\n",
" <td>38183.766184</td>\n",
" <td>5.500000</td>\n",
" <td>2.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>21</th>\n",
" <td>Scala</td>\n",
" <td>16</td>\n",
" <td>52620.0</td>\n",
" <td>50121.125000</td>\n",
" <td>23552.075724</td>\n",
" <td>6.875000</td>\n",
" <td>6.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Bash</td>\n",
" <td>75</td>\n",
" <td>46000.0</td>\n",
" <td>53413.440000</td>\n",
" <td>27409.021714</td>\n",
" <td>8.853333</td>\n",
" <td>12.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>12</th>\n",
" <td>Kotlin</td>\n",
" <td>32</td>\n",
" <td>45000.0</td>\n",
" <td>49453.125000</td>\n",
" <td>42223.934387</td>\n",
" <td>6.625000</td>\n",
" <td>8.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>17</th>\n",
" <td>Python</td>\n",
" <td>188</td>\n",
" <td>43000.0</td>\n",
" <td>48455.893617</td>\n",
" <td>34555.416420</td>\n",
" <td>8.255319</td>\n",
" <td>19.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>22</th>\n",
" <td>Swift</td>\n",
" <td>14</td>\n",
" <td>40500.0</td>\n",
" <td>41778.571429</td>\n",
" <td>19033.823278</td>\n",
" <td>6.642857</td>\n",
" <td>5.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>Java</td>\n",
" <td>272</td>\n",
" <td>40000.0</td>\n",
" <td>46515.036765</td>\n",
" <td>34136.856233</td>\n",
" <td>8.639706</td>\n",
" <td>23.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>11</th>\n",
" <td>JavaScript</td>\n",
" <td>477</td>\n",
" <td>40000.0</td>\n",
" <td>46796.075472</td>\n",
" <td>35276.376943</td>\n",
" <td>7.622642</td>\n",
" <td>31.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>COBOL</td>\n",
" <td>8</td>\n",
" <td>39500.0</td>\n",
" <td>38187.500000</td>\n",
" <td>10246.732929</td>\n",
" <td>17.125000</td>\n",
" <td>4.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>C/C++</td>\n",
" <td>18</td>\n",
" <td>37500.0</td>\n",
" <td>38693.000000</td>\n",
" <td>15247.243037</td>\n",
" <td>8.388889</td>\n",
" <td>6.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>Groovy</td>\n",
" <td>16</td>\n",
" <td>36500.0</td>\n",
" <td>71345.437500</td>\n",
" <td>75274.059541</td>\n",
" <td>7.062500</td>\n",
" <td>6.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>Ensamblador</td>\n",
" <td>2</td>\n",
" <td>35000.0</td>\n",
" <td>35000.000000</td>\n",
" <td>7071.067812</td>\n",
" <td>24.000000</td>\n",
" <td>2.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>16</th>\n",
" <td>PL/SQL</td>\n",
" <td>150</td>\n",
" <td>34500.0</td>\n",
" <td>43932.726667</td>\n",
" <td>42329.664339</td>\n",
" <td>9.400000</td>\n",
" <td>17.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>C#</td>\n",
" <td>156</td>\n",
" <td>32500.0</td>\n",
" <td>38927.673077</td>\n",
" <td>29408.029557</td>\n",
" <td>9.884615</td>\n",
" <td>18.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>15</th>\n",
" <td>PHP</td>\n",
" <td>175</td>\n",
" <td>32000.0</td>\n",
" <td>43045.240000</td>\n",
" <td>37759.731835</td>\n",
" <td>8.885714</td>\n",
" <td>19.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>Dart</td>\n",
" <td>10</td>\n",
" <td>29000.0</td>\n",
" <td>35300.000000</td>\n",
" <td>22662.009325</td>\n",
" <td>10.400000</td>\n",
" <td>4.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>23</th>\n",
" <td>VB .NET</td>\n",
" <td>37</td>\n",
" <td>26500.0</td>\n",
" <td>32832.270270</td>\n",
" <td>28158.928851</td>\n",
" <td>10.189189</td>\n",
" <td>9.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>Delphi</td>\n",
" <td>6</td>\n",
" <td>24000.0</td>\n",
" <td>24533.333333</td>\n",
" <td>10603.144188</td>\n",
" <td>14.500000</td>\n",
" <td>3.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>18</th>\n",
" <td>R</td>\n",
" <td>8</td>\n",
" <td>23500.0</td>\n",
" <td>27606.250000</td>\n",
" <td>15309.111141</td>\n",
" <td>8.500000</td>\n",
" <td>4.0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" lenguaje n mediana ... std exp popularidad\n",
"20 Rust 4 73000.0 ... 95819.329154 10.250000 3.0\n",
"6 Elixir 14 72500.0 ... 27402.273909 7.785714 5.0\n",
"13 Objective C 4 66250.0 ... 25042.680235 6.750000 3.0\n",
"19 Ruby 53 60000.0 ... 40928.739867 7.867925 10.0\n",
"8 Go 39 55000.0 ... 37490.435127 7.743590 9.0\n",
"14 Perl 2 53000.0 ... 38183.766184 5.500000 2.0\n",
"21 Scala 16 52620.0 ... 23552.075724 6.875000 6.0\n",
"0 Bash 75 46000.0 ... 27409.021714 8.853333 12.0\n",
"12 Kotlin 32 45000.0 ... 42223.934387 6.625000 8.0\n",
"17 Python 188 43000.0 ... 34555.416420 8.255319 19.0\n",
"22 Swift 14 40500.0 ... 19033.823278 6.642857 5.0\n",
"10 Java 272 40000.0 ... 34136.856233 8.639706 23.0\n",
"11 JavaScript 477 40000.0 ... 35276.376943 7.622642 31.0\n",
"3 COBOL 8 39500.0 ... 10246.732929 17.125000 4.0\n",
"2 C/C++ 18 37500.0 ... 15247.243037 8.388889 6.0\n",
"9 Groovy 16 36500.0 ... 75274.059541 7.062500 6.0\n",
"7 Ensamblador 2 35000.0 ... 7071.067812 24.000000 2.0\n",
"16 PL/SQL 150 34500.0 ... 42329.664339 9.400000 17.0\n",
"1 C# 156 32500.0 ... 29408.029557 9.884615 18.0\n",
"15 PHP 175 32000.0 ... 37759.731835 8.885714 19.0\n",
"4 Dart 10 29000.0 ... 22662.009325 10.400000 4.0\n",
"23 VB .NET 37 26500.0 ... 28158.928851 10.189189 9.0\n",
"5 Delphi 6 24000.0 ... 10603.144188 14.500000 3.0\n",
"18 R 8 23500.0 ... 15309.111141 8.500000 4.0\n",
"\n",
"[24 rows x 7 columns]"
]
},
"metadata": {
"tags": []
},
"execution_count": 83
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "J6_2enjyRqaa"
},
"source": [
"item_df.to_csv('table_langs.csv')"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "yklsobaP1pY2",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 617
},
"outputId": "53b0e955-7e47-4f5a-e67f-a2eeb3a75353"
},
"source": [
"from bokeh.models import LabelSet\n",
"from bokeh.models import Range1d\n",
"\n",
"src = ColumnDataSource(langdf)\n",
"p = figure()\n",
"# Ponemos los circulos invisibles pero con tamaño para que sirvan los tooltips en hover.\n",
"p.circle(source=src, y='popularidad', x='mediana', line_color=None, fill_color=None, size=20)\n",
"p.yaxis.axis_label = 'Popularidad'\n",
"\n",
"# La escala de popularidad tiene unidades arbitrarias así que prefiero evitar que se despliegue.\n",
"p.yaxis.major_label_text_font_size = '0pt'\n",
"\n",
"p.xaxis.axis_label = 'Salario bruto mensual (MXN)'\n",
"p.xaxis.formatter = NumeralTickFormatter(format='$0 a') \n",
"p.x_range = Range1d(10000, 70000)\n",
"\n",
"labels = LabelSet(source=src, x='mediana', y='popularidad', text='lenguaje', level='glyph',\n",
" x_offset=-10, y_offset=-5, render_mode='canvas', text_font_size=\"9pt\", text_color='#1f77b4')\n",
"p.add_layout(labels)\n",
"\n",
"hover = HoverTool()\n",
"hover.tooltips=[\n",
" ('Lenguaje', '@lenguaje'),\n",
" ('Observaciones', '@count'),\n",
" ('Salario medio', '@salario{$0,0}'),\n",
"]\n",
"\n",
"p.add_tools(hover)\n",
"\n",
"show(p)"
],
"execution_count": null,
"outputs": [
{
"output_type": "display_data",
"data": {
"application/javascript": [
"\n",
"(function(root) {\n",
" function now() {\n",
" return new Date();\n",
" }\n",
"\n",
" var force = true;\n",
"\n",
" if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n",
" root._bokeh_onload_callbacks = [];\n",
" root._bokeh_is_loading = undefined;\n",
" }\n",
"\n",
" var JS_MIME_TYPE = 'application/javascript';\n",
" var HTML_MIME_TYPE = 'text/html';\n",
" var EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n",
" var CLASS_NAME = 'output_bokeh rendered_html';\n",
"\n",
" /**\n",
" * Render data to the DOM node\n",
" */\n",
" function render(props, node) {\n",
" var script = document.createElement(\"script\");\n",
" node.appendChild(script);\n",
" }\n",
"\n",
" /**\n",
" * Handle when an output is cleared or removed\n",
" */\n",
" function handleClearOutput(event, handle) {\n",
" var cell = handle.cell;\n",
"\n",
" var id = cell.output_area._bokeh_element_id;\n",
" var server_id = cell.output_area._bokeh_server_id;\n",
" // Clean up Bokeh references\n",
" if (id != null && id in Bokeh.index) {\n",
" Bokeh.index[id].model.document.clear();\n",
" delete Bokeh.index[id];\n",
" }\n",
"\n",
" if (server_id !== undefined) {\n",
" // Clean up Bokeh references\n",
" var cmd = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n",
" cell.notebook.kernel.execute(cmd, {\n",
" iopub: {\n",
" output: function(msg) {\n",
" var id = msg.content.text.trim();\n",
" if (id in Bokeh.index) {\n",
" Bokeh.index[id].model.document.clear();\n",
" delete Bokeh.index[id];\n",
" }\n",
" }\n",
" }\n",
" });\n",
" // Destroy server and session\n",
" var cmd = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n",
" cell.notebook.kernel.execute(cmd);\n",
" }\n",
" }\n",
"\n",
" /**\n",
" * Handle when a new output is added\n",
" */\n",
" function handleAddOutput(event, handle) {\n",
" var output_area = handle.output_area;\n",
" var output = handle.output;\n",
"\n",
" // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n",
" if ((output.output_type != \"display_data\") || (!output.data.hasOwnProperty(EXEC_MIME_TYPE))) {\n",
" return\n",
" }\n",
"\n",
" var toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n",
"\n",
" if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n",
" toinsert[toinsert.length - 1].firstChild.textContent = output.data[JS_MIME_TYPE];\n",
" // store reference to embed id on output_area\n",
" output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n",
" }\n",
" if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n",
" var bk_div = document.createElement(\"div\");\n",
" bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n",
" var script_attrs = bk_div.children[0].attributes;\n",
" for (var i = 0; i < script_attrs.length; i++) {\n",
" toinsert[toinsert.length - 1].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n",
" toinsert[toinsert.length - 1].firstChild.textContent = bk_div.children[0].textContent\n",
" }\n",
" // store reference to server id on output_area\n",
" output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n",
" }\n",
" }\n",
"\n",
" function register_renderer(events, OutputArea) {\n",
"\n",
" function append_mime(data, metadata, element) {\n",
" // create a DOM node to render to\n",
" var toinsert = this.create_output_subarea(\n",
" metadata,\n",
" CLASS_NAME,\n",
" EXEC_MIME_TYPE\n",
" );\n",
" this.keyboard_manager.register_events(toinsert);\n",
" // Render to node\n",
" var props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n",
" render(props, toinsert[toinsert.length - 1]);\n",
" element.append(toinsert);\n",
" return toinsert\n",
" }\n",
"\n",
" /* Handle when an output is cleared or removed */\n",
" events.on('clear_output.CodeCell', handleClearOutput);\n",
" events.on('delete.Cell', handleClearOutput);\n",
"\n",
" /* Handle when a new output is added */\n",
" events.on('output_added.OutputArea', handleAddOutput);\n",
"\n",
" /**\n",
" * Register the mime type and append_mime function with output_area\n",
" */\n",
" OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n",
" /* Is output safe? */\n",
" safe: true,\n",
" /* Index of renderer in `output_area.display_order` */\n",
" index: 0\n",
" });\n",
" }\n",
"\n",
" // register the mime type if in Jupyter Notebook environment and previously unregistered\n",
" if (root.Jupyter !== undefined) {\n",
" var events = require('base/js/events');\n",
" var OutputArea = require('notebook/js/outputarea').OutputArea;\n",
"\n",
" if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n",
" register_renderer(events, OutputArea);\n",
" }\n",
" }\n",
"\n",
" \n",
" if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n",
" root._bokeh_timeout = Date.now() + 5000;\n",
" root._bokeh_failed_load = false;\n",
" }\n",
"\n",
" var NB_LOAD_WARNING = {'data': {'text/html':\n",
" \"<div style='background-color: #fdd'>\\n\"+\n",
" \"<p>\\n\"+\n",
" \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n",
" \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n",
" \"</p>\\n\"+\n",
" \"<ul>\\n\"+\n",
" \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n",
" \"<li>use INLINE resources instead, as so:</li>\\n\"+\n",
" \"</ul>\\n\"+\n",
" \"<code>\\n\"+\n",
" \"from bokeh.resources import INLINE\\n\"+\n",
" \"output_notebook(resources=INLINE)\\n\"+\n",
" \"</code>\\n\"+\n",
" \"</div>\"}};\n",
"\n",
" function display_loaded() {\n",
" var el = document.getElementById(null);\n",
" if (el != null) {\n",
" el.textContent = \"BokehJS is loading...\";\n",
" }\n",
" if (root.Bokeh !== undefined) {\n",
" if (el != null) {\n",
" el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n",
" }\n",
" } else if (Date.now() < root._bokeh_timeout) {\n",
" setTimeout(display_loaded, 100)\n",
" }\n",
" }\n",
"\n",
"\n",
" function run_callbacks() {\n",
" try {\n",
" root._bokeh_onload_callbacks.forEach(function(callback) {\n",
" if (callback != null)\n",
" callback();\n",
" });\n",
" } finally {\n",
" delete root._bokeh_onload_callbacks\n",
" }\n",
" console.debug(\"Bokeh: all callbacks have finished\");\n",
" }\n",
"\n",
" function load_libs(css_urls, js_urls, callback) {\n",
" if (css_urls == null) css_urls = [];\n",
" if (js_urls == null) js_urls = [];\n",
"\n",
" root._bokeh_onload_callbacks.push(callback);\n",
" if (root._bokeh_is_loading > 0) {\n",
" console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n",
" return null;\n",
" }\n",
" if (js_urls == null || js_urls.length === 0) {\n",
" run_callbacks();\n",
" return null;\n",
" }\n",
" console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n",
" root._bokeh_is_loading = css_urls.length + js_urls.length;\n",
"\n",
" function on_load() {\n",
" root._bokeh_is_loading--;\n",
" if (root._bokeh_is_loading === 0) {\n",
" console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n",
" run_callbacks()\n",
" }\n",
" }\n",
"\n",
" function on_error() {\n",
" console.error(\"failed to load \" + url);\n",
" }\n",
"\n",
" for (var i = 0; i < css_urls.length; i++) {\n",
" var url = css_urls[i];\n",
" const element = document.createElement(\"link\");\n",
" element.onload = on_load;\n",
" element.onerror = on_error;\n",
" element.rel = \"stylesheet\";\n",
" element.type = \"text/css\";\n",
" element.href = url;\n",
" console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n",
" document.body.appendChild(element);\n",
" }\n",
"\n",
" const hashes = {\"https://cdn.bokeh.org/bokeh/release/bokeh-2.1.1.min.js\": \"kLr4fYcqcSpbuI95brIH3vnnYCquzzSxHPU6XGQCIkQRGJwhg0StNbj1eegrHs12\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.1.1.min.js\": \"xIGPmVtaOm+z0BqfSOMn4lOR6ciex448GIKG4eE61LsAvmGj48XcMQZtKcE/UXZe\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.1.1.min.js\": \"Dc9u1wF/0zApGIWoBbH77iWEHtdmkuYWG839Uzmv8y8yBLXebjO9ZnERsde5Ln/P\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.1.1.min.js\": \"cT9JaBz7GiRXdENrJLZNSC6eMNF3nh3fa5fTF51Svp+ukxPdwcU5kGXGPBgDCa2j\"};\n",
"\n",
" for (var i = 0; i < js_urls.length; i++) {\n",
" var url = js_urls[i];\n",
" var element = document.createElement('script');\n",
" element.onload = on_load;\n",
" element.onerror = on_error;\n",
" element.async = false;\n",
" element.src = url;\n",
" if (url in hashes) {\n",
" element.crossOrigin = \"anonymous\";\n",
" element.integrity = \"sha384-\" + hashes[url];\n",
" }\n",
" console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n",
" document.head.appendChild(element);\n",
" }\n",
" };\n",
"\n",
" function inject_raw_css(css) {\n",
" const element = document.createElement(\"style\");\n",
" element.appendChild(document.createTextNode(css));\n",
" document.body.appendChild(element);\n",
" }\n",
"\n",
" \n",
" var js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.1.1.min.js\"];\n",
" var css_urls = [];\n",
" \n",
"\n",
" var inline_js = [\n",
" function(Bokeh) {\n",
" Bokeh.set_log_level(\"info\");\n",
" },\n",
" function(Bokeh) {\n",
" \n",
" \n",
" }\n",
" ];\n",
"\n",
" function run_inline_js() {\n",
" \n",
" if (root.Bokeh !== undefined || force === true) {\n",
" \n",
" for (var i = 0; i < inline_js.length; i++) {\n",
" inline_js[i].call(root, root.Bokeh);\n",
" }\n",
" } else if (Date.now() < root._bokeh_timeout) {\n",
" setTimeout(run_inline_js, 100);\n",
" } else if (!root._bokeh_failed_load) {\n",
" console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n",
" root._bokeh_failed_load = true;\n",
" } else if (force !== true) {\n",
" var cell = $(document.getElementById(null)).parents('.cell').data().cell;\n",
" cell.output_area.append_execute_result(NB_LOAD_WARNING)\n",
" }\n",
"\n",
" }\n",
"\n",
" if (root._bokeh_is_loading === 0) {\n",
" console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n",
" run_inline_js();\n",
" } else {\n",
" load_libs(css_urls, js_urls, function() {\n",
" console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n",
" run_inline_js();\n",
" });\n",
" }\n",
"}(window));"
],
"application/vnd.bokehjs_load.v0+json": "\n(function(root) {\n function now() {\n return new Date();\n }\n\n var force = true;\n\n if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\n \n\n \n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n var NB_LOAD_WARNING = {'data': {'text/html':\n \"<div style='background-color: #fdd'>\\n\"+\n \"<p>\\n\"+\n \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n \"</p>\\n\"+\n \"<ul>\\n\"+\n \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n \"<li>use INLINE resources instead, as so:</li>\\n\"+\n \"</ul>\\n\"+\n \"<code>\\n\"+\n \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"</code>\\n\"+\n \"</div>\"}};\n\n function display_loaded() {\n var el = document.getElementById(null);\n if (el != null) {\n el.textContent = \"BokehJS is loading...\";\n }\n if (root.Bokeh !== undefined) {\n if (el != null) {\n el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(display_loaded, 100)\n }\n }\n\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) {\n if (callback != null)\n callback();\n });\n } finally {\n delete root._bokeh_onload_callbacks\n }\n console.debug(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(css_urls, js_urls, callback) {\n if (css_urls == null) css_urls = [];\n if (js_urls == null) js_urls = [];\n\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls == null || js_urls.length === 0) {\n run_callbacks();\n return null;\n }\n console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n root._bokeh_is_loading = css_urls.length + js_urls.length;\n\n function on_load() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n run_callbacks()\n }\n }\n\n function on_error() {\n console.error(\"failed to load \" + url);\n }\n\n for (var i = 0; i < css_urls.length; i++) {\n var url = css_urls[i];\n const element = document.createElement(\"link\");\n element.onload = on_load;\n element.onerror = on_error;\n element.rel = \"stylesheet\";\n element.type = \"text/css\";\n element.href = url;\n console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n document.body.appendChild(element);\n }\n\n const hashes = {\"https://cdn.bokeh.org/bokeh/release/bokeh-2.1.1.min.js\": \"kLr4fYcqcSpbuI95brIH3vnnYCquzzSxHPU6XGQCIkQRGJwhg0StNbj1eegrHs12\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.1.1.min.js\": \"xIGPmVtaOm+z0BqfSOMn4lOR6ciex448GIKG4eE61LsAvmGj48XcMQZtKcE/UXZe\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.1.1.min.js\": \"Dc9u1wF/0zApGIWoBbH77iWEHtdmkuYWG839Uzmv8y8yBLXebjO9ZnERsde5Ln/P\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.1.1.min.js\": \"cT9JaBz7GiRXdENrJLZNSC6eMNF3nh3fa5fTF51Svp+ukxPdwcU5kGXGPBgDCa2j\"};\n\n for (var i = 0; i < js_urls.length; i++) {\n var url = js_urls[i];\n var element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error;\n element.async = false;\n element.src = url;\n if (url in hashes) {\n element.crossOrigin = \"anonymous\";\n element.integrity = \"sha384-\" + hashes[url];\n }\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n };\n\n function inject_raw_css(css) {\n const element = document.createElement(\"style\");\n element.appendChild(document.createTextNode(css));\n document.body.appendChild(element);\n }\n\n \n var js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.1.1.min.js\"];\n var css_urls = [];\n \n\n var inline_js = [\n function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\n function(Bokeh) {\n \n \n }\n ];\n\n function run_inline_js() {\n \n if (root.Bokeh !== undefined || force === true) {\n \n for (var i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n } else if (force !== true) {\n var cell = $(document.getElementById(null)).parents('.cell').data().cell;\n cell.output_area.append_execute_result(NB_LOAD_WARNING)\n }\n\n }\n\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(css_urls, js_urls, function() {\n console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));"
},
"metadata": {
"tags": []
}
},
{
"output_type": "display_data",
"data": {
"text/html": [
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
" <div class=\"bk-root\" id=\"6f53ba3f-66ab-4e8a-aab8-5a4b4aaa351c\" data-root-id=\"1799\"></div>\n"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "display_data",
"data": {
"application/javascript": [
"(function(root) {\n",
" function embed_document(root) {\n",
" \n",
" var docs_json = {\"218214c3-ddd0-4243-8247-e63d81d03ae0\":{\"roots\":{\"references\":[{\"attributes\":{\"below\":[{\"id\":\"1808\"}],\"center\":[{\"id\":\"1811\"},{\"id\":\"1815\"},{\"id\":\"1838\"}],\"left\":[{\"id\":\"1812\"}],\"renderers\":[{\"id\":\"1833\"}],\"title\":{\"id\":\"1893\"},\"toolbar\":{\"id\":\"1823\"},\"x_range\":{\"id\":\"1837\"},\"x_scale\":{\"id\":\"1804\"},\"y_range\":{\"id\":\"1802\"},\"y_scale\":{\"id\":\"1806\"}},\"id\":\"1799\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{},\"id\":\"1898\",\"type\":\"Selection\"},{\"attributes\":{\"text\":\"\"},\"id\":\"1893\",\"type\":\"Title\"},{\"attributes\":{\"format\":\"$0 a\"},\"id\":\"1835\",\"type\":\"NumeralTickFormatter\"},{\"attributes\":{\"end\":70000,\"start\":10000},\"id\":\"1837\",\"type\":\"Range1d\"},{\"attributes\":{\"data\":{\"exp\":{\"__ndarray__\":\"tYFOG+i0IUBP7MRO7MQjQHIcx3EcxyBAAAAAAAAgMUDNzMzMzMwkQAAAAAAAAC1ASZIkSZIkH0AAAAAAAAA4QJdv+ZZv+R5AAAAAAABAHECIh4eHh0chQJGaYLyVfR5AAAAAAACAGkAAAAAAAAAbQAAAAAAAABZAWHzFV3zFIUDNzMzMzMwiQGJyBTG5giBAAAAAAAAAIUCzzyE1wXgfQAAAAAAAgCRAAAAAAACAG0AlSZIkSZIaQA6myGfdYCRA\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[24]},\"index\":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23],\"lenguaje\":[\"Bash\",\"C#\",\"C/C++\",\"COBOL\",\"Dart\",\"Delphi\",\"Elixir\",\"Ensamblador\",\"Go\",\"Groovy\",\"Java\",\"JavaScript\",\"Kotlin\",\"Objective C\",\"Perl\",\"PHP\",\"PL/SQL\",\"Python\",\"R\",\"Ruby\",\"Rust\",\"Scala\",\"Swift\",\"VB .NET\"],\"media\":{\"__ndarray__\":\"SOF6FK4U6kCKndiJ9QHjQAAAAACg5OJAAAAAAHCl4kAAAAAAgDzhQFVVVVVV9ddAAAAAAMB08UAAAAAAABfhQEIapEGavu9AAAAAABdr8UAtLS0tYbbmQGWfQ2qC2eZAAAAAAKQl6EAAAAAAIG7sQAAAAAAA4elA4XoUrqcE5UAOdNpAl3PlQDG5gpj8qOdAAAAAAJD12kCzzyE1YVjxQAAAAADMJPlAAAAAACR56EBJkiRJUmbkQH3WDaYICOBA\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[24]},\"mediana\":{\"__ndarray__\":\"AAAAAAB25kAAAAAAAL3fQAAAAACAT+JAAAAAAIBJ40AAAAAAAFLcQAAAAAAAcNdAAAAAAECz8UAAAAAAABfhQAAAAAAA2+pAAAAAAIDS4UAAAAAAAIjjQAAAAAAAiONAAAAAAAD55UAAAAAAoCzwQAAAAAAA4elAAAAAAABA30AAAAAAgNjgQAAAAAAA/+RAAAAAAADz1kAAAAAAAEztQAAAAACA0vFAAAAAAICx6UAAAAAAgMbjQAAAAAAA4dlA\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[24]},\"n\":[75,156,18,8,10,6,14,2,39,16,272,477,32,4,2,175,150,188,8,53,4,16,14,37],\"popularidad\":{\"__ndarray__\":\"AAAAAAAAKEAAAAAAAAAyQAAAAAAAABhAAAAAAAAAEEAAAAAAAAAQQAAAAAAAAAhAAAAAAAAAFEAAAAAAAAAAQAAAAAAAACJAAAAAAAAAGEAAAAAAAAA3QAAAAAAAAD9AAAAAAAAAIEAAAAAAAAAIQAAAAAAAAABAAAAAAAAAM0AAAAAAAAAxQAAAAAAAADNAAAAAAAAAEEAAAAAAAAAkQAAAAAAAAAhAAAAAAAAAGEAAAAAAAAAUQAAAAAAAACJA\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[24]},\"std\":{\"__ndarray__\":\"PP3BY0HE2kBKOUPkAbjcQE/C1xufx81A7XKc0F0DxEDxwsmYgCHWQPGwvnSStcRAB6y5h5HC2kB/UB5cEZ+7QGdpkOxNTuJAQuXg86Bg8kCUfkNmG6vgQOcp6w+MOeFAZqV+5v2d5ECdx/aIq3TYQFZ2lIT4pOJAOzoya/dv4kDQW0RCNavkQFXxT1Nt3+BA85PeOY7mzUD7zfysF/zjQCpRN0S1ZPdA9Seq2AQA10A6eJWwdJbSQMB9S3K7f9tA\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[24]}},\"selected\":{\"id\":\"1898\"},\"selection_policy\":{\"id\":\"1899\"}},\"id\":\"1798\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"axis\":{\"id\":\"1808\"},\"ticker\":null},\"id\":\"1811\",\"type\":\"Grid\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":null},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":null},\"size\":{\"units\":\"screen\",\"value\":20},\"x\":{\"field\":\"mediana\"},\"y\":{\"field\":\"popularidad\"}},\"id\":\"1832\",\"type\":\"Circle\"},{\"attributes\":{\"callback\":null,\"tooltips\":[[\"Lenguaje\",\"@lenguaje\"],[\"Observaciones\",\"@count\"],[\"Salario medio\",\"@salario{$0,0}\"]]},\"id\":\"1840\",\"type\":\"HoverTool\"},{\"attributes\":{\"axis\":{\"id\":\"1812\"},\"dimension\":1,\"ticker\":null},\"id\":\"1815\",\"type\":\"Grid\"},{\"attributes\":{\"axis_label\":\"Popularidad\",\"formatter\":{\"id\":\"1894\"},\"major_label_text_font_size\":\"0pt\",\"ticker\":{\"id\":\"1813\"}},\"id\":\"1812\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"1806\",\"type\":\"LinearScale\"},{\"attributes\":{},\"id\":\"1809\",\"type\":\"BasicTicker\"},{\"attributes\":{},\"id\":\"1820\",\"type\":\"ResetTool\"},{\"attributes\":{},\"id\":\"1802\",\"type\":\"DataRange1d\"},{\"attributes\":{},\"id\":\"1817\",\"type\":\"WheelZoomTool\"},{\"attributes\":{\"axis_label\":\"Salario bruto mensual (MXN)\",\"formatter\":{\"id\":\"1835\"},\"ticker\":{\"id\":\"1809\"}},\"id\":\"1808\",\"type\":\"LinearAxis\"},{\"attributes\":{\"level\":\"glyph\",\"source\":{\"id\":\"1798\"},\"text\":{\"field\":\"lenguaje\"},\"text_color\":{\"value\":\"#1f77b4\"},\"text_font_size\":{\"value\":\"9pt\"},\"x\":{\"field\":\"mediana\"},\"x_offset\":{\"value\":-10},\"y\":{\"field\":\"popularidad\"},\"y_offset\":{\"value\":-5}},\"id\":\"1838\",\"type\":\"LabelSet\"},{\"attributes\":{\"fill_color\":{\"value\":null},\"line_color\":{\"value\":null},\"size\":{\"units\":\"screen\",\"value\":20},\"x\":{\"field\":\"mediana\"},\"y\":{\"field\":\"popularidad\"}},\"id\":\"1831\",\"type\":\"Circle\"},{\"attributes\":{\"data_source\":{\"id\":\"1798\"},\"glyph\":{\"id\":\"1831\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"1832\"},\"selection_glyph\":null,\"view\":{\"id\":\"1834\"}},\"id\":\"1833\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"1819\",\"type\":\"SaveTool\"},{\"attributes\":{},\"id\":\"1894\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{},\"id\":\"1821\",\"type\":\"HelpTool\"},{\"attributes\":{},\"id\":\"1813\",\"type\":\"BasicTicker\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":0.5,\"fill_color\":\"lightgrey\",\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":1.0,\"line_color\":\"black\",\"line_dash\":[4,4],\"line_width\":2,\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"1822\",\"type\":\"BoxAnnotation\"},{\"attributes\":{},\"id\":\"1899\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"overlay\":{\"id\":\"1822\"}},\"id\":\"1818\",\"type\":\"BoxZoomTool\"},{\"attributes\":{},\"id\":\"1816\",\"type\":\"PanTool\"},{\"attributes\":{\"source\":{\"id\":\"1798\"}},\"id\":\"1834\",\"type\":\"CDSView\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_multi\":null,\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"1816\"},{\"id\":\"1817\"},{\"id\":\"1818\"},{\"id\":\"1819\"},{\"id\":\"1820\"},{\"id\":\"1821\"},{\"id\":\"1840\"}]},\"id\":\"1823\",\"type\":\"Toolbar\"},{\"attributes\":{},\"id\":\"1804\",\"type\":\"LinearScale\"}],\"root_ids\":[\"1799\"]},\"title\":\"Bokeh Application\",\"version\":\"2.1.1\"}};\n",
" var render_items = [{\"docid\":\"218214c3-ddd0-4243-8247-e63d81d03ae0\",\"root_ids\":[\"1799\"],\"roots\":{\"1799\":\"6f53ba3f-66ab-4e8a-aab8-5a4b4aaa351c\"}}];\n",
" root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n",
"\n",
" }\n",
" if (root.Bokeh !== undefined) {\n",
" embed_document(root);\n",
" } else {\n",
" var attempts = 0;\n",
" var timer = setInterval(function(root) {\n",
" if (root.Bokeh !== undefined) {\n",
" clearInterval(timer);\n",
" embed_document(root);\n",
" } else {\n",
" attempts++;\n",
" if (attempts > 100) {\n",
" clearInterval(timer);\n",
" console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n",
" }\n",
" }\n",
" }, 10, root)\n",
" }\n",
"})(window);"
],
"application/vnd.bokehjs_exec.v0+json": ""
},
"metadata": {
"tags": [],
"application/vnd.bokehjs_exec.v0+json": {
"id": "1799"
}
}
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "37L7_3hF1pY2"
},
"source": [
"## Front end"
]
},
{
"cell_type": "code",
"metadata": {
"id": "kOp7ZweD1pY2",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 373
},
"outputId": "b5fd913e-734e-4f48-fbbb-008a4fbfd1d8"
},
"source": [
"# Inicializamos nuestra lista maestra\n",
"item_list = []\n",
"# URL del catálogo\n",
"url = 'https://raw.githubusercontent.com/softwareguru/salarios-notebook/main/front_options.csv'\n",
"reader = get_remote_csv_reader(url)\n",
"\n",
"for row in reader:\n",
" item_key = \"front_\"+row['key']\n",
" # Por cada elemento en la lista agregamos un renglon con el nombre de la categoria y estadisticas agregadas.\n",
" item_list.append([row['name'], df[(df[item_key]==\"Y\")][\"salarymx\"].count(), df[(df[item_key]==\"Y\")][\"salarymx\"].median(), df[(df[item_key]==\"Y\")][\"salarymx\"].mean(), df[(df[item_key]==\"Y\")][\"salarymx\"].std(), df[(df[item_key]==\"Y\")][\"experience\"].mean()])\n",
"\n",
"# Una vez que tenemos la lista maestra completa, creamos un dataframe indicando el nombre de las columnas.\n",
"item_df = pd.DataFrame(item_list, columns = ['Tecnologia front', 'n', 'mediana','media', 'std', 'exp'])\n",
"# Agregamos una columna de popularidad que se calcule en base a un valor amortiguado del número de observaciones. \n",
"item_df.sort_values(by=['mediana'], ascending=False).head(30)"
],
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Tecnologia front</th>\n",
" <th>n</th>\n",
" <th>mediana</th>\n",
" <th>media</th>\n",
" <th>std</th>\n",
" <th>exp</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>React</td>\n",
" <td>271</td>\n",
" <td>44000.0</td>\n",
" <td>51992.571956</td>\n",
" <td>39906.386094</td>\n",
" <td>7.022140</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>Unity</td>\n",
" <td>7</td>\n",
" <td>42000.0</td>\n",
" <td>36428.428571</td>\n",
" <td>22066.804419</td>\n",
" <td>10.285714</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>Qt</td>\n",
" <td>1</td>\n",
" <td>39000.0</td>\n",
" <td>39000.000000</td>\n",
" <td>NaN</td>\n",
" <td>7.000000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>Ionic</td>\n",
" <td>27</td>\n",
" <td>38000.0</td>\n",
" <td>41052.370370</td>\n",
" <td>27464.496904</td>\n",
" <td>7.000000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>Flutter</td>\n",
" <td>29</td>\n",
" <td>35000.0</td>\n",
" <td>34534.965517</td>\n",
" <td>22054.124931</td>\n",
" <td>7.344828</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Angular</td>\n",
" <td>179</td>\n",
" <td>33400.0</td>\n",
" <td>39859.759777</td>\n",
" <td>29893.520173</td>\n",
" <td>7.664804</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>Cordova / PhoneGap</td>\n",
" <td>11</td>\n",
" <td>33000.0</td>\n",
" <td>40095.454545</td>\n",
" <td>25576.751695</td>\n",
" <td>7.545455</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>Vue</td>\n",
" <td>111</td>\n",
" <td>32000.0</td>\n",
" <td>41087.117117</td>\n",
" <td>33448.453717</td>\n",
" <td>6.405405</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>Xamarin</td>\n",
" <td>12</td>\n",
" <td>29500.0</td>\n",
" <td>42708.333333</td>\n",
" <td>45908.237691</td>\n",
" <td>7.500000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>NativeScript</td>\n",
" <td>22</td>\n",
" <td>24950.0</td>\n",
" <td>31740.909091</td>\n",
" <td>16081.034647</td>\n",
" <td>9.545455</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>Electron</td>\n",
" <td>9</td>\n",
" <td>17000.0</td>\n",
" <td>60000.000000</td>\n",
" <td>83393.644842</td>\n",
" <td>6.444444</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Tecnologia front n mediana media std exp\n",
"4 React 271 44000.0 51992.571956 39906.386094 7.022140\n",
"5 Unity 7 42000.0 36428.428571 22066.804419 10.285714\n",
"10 Qt 1 39000.0 39000.000000 NaN 7.000000\n",
"2 Ionic 27 38000.0 41052.370370 27464.496904 7.000000\n",
"9 Flutter 29 35000.0 34534.965517 22054.124931 7.344828\n",
"0 Angular 179 33400.0 39859.759777 29893.520173 7.664804\n",
"1 Cordova / PhoneGap 11 33000.0 40095.454545 25576.751695 7.545455\n",
"6 Vue 111 32000.0 41087.117117 33448.453717 6.405405\n",
"7 Xamarin 12 29500.0 42708.333333 45908.237691 7.500000\n",
"3 NativeScript 22 24950.0 31740.909091 16081.034647 9.545455\n",
"8 Electron 9 17000.0 60000.000000 83393.644842 6.444444"
]
},
"metadata": {
"tags": []
},
"execution_count": 68
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "LRHvv15qSJTC"
},
"source": [
"item_df.to_csv('table_front.csv')"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "4I9G4ujV1pY3"
},
"source": [
"## Certificaciones"
]
},
{
"cell_type": "code",
"metadata": {
"id": "9vZblAFc1pY4",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 817
},
"outputId": "233ee39a-f976-4ff5-d939-4d6ad2943657"
},
"source": [
"# Inicializamos nuestra lista maestra\n",
"item_list = []\n",
"# URL del catálogo\n",
"url = 'https://raw.githubusercontent.com/softwareguru/salarios-notebook/main/cert_options.csv'\n",
"reader = get_remote_csv_reader(url)\n",
"\n",
"for row in reader:\n",
" item_key = \"cert_\"+row['key']\n",
" # Por cada elemento en la lista agregamos un renglon con el nombre de la categoria y estadisticas agregadas.\n",
" item_list.append([row['name'], df[(df[item_key]==\"Y\")][\"salarymx\"].count(), df[(df[item_key]==\"Y\")][\"salarymx\"].median(), df[(df[item_key]==\"Y\")][\"salarymx\"].mean(), df[(df[item_key]==\"Y\")][\"salarymx\"].std(), df[(df[item_key]==\"Y\")][\"experience\"].mean()])\n",
"\n",
"# Una vez que tenemos la lista maestra completa, creamos un dataframe indicando el nombre de las columnas.\n",
"itemdf = pd.DataFrame(item_list, columns = ['Certificacion', 'n', 'mediana','media', 'std', 'exp'])\n",
"# Agregamos una columna de popularidad que se calcule en base a un valor amortiguado del número de observaciones. \n",
"itemdf.sort_values(by=['mediana'], ascending=False).head(30)"
],
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Certificacion</th>\n",
" <th>n</th>\n",
" <th>mediana</th>\n",
" <th>media</th>\n",
" <th>std</th>\n",
" <th>exp</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>Google Cloud Architect</td>\n",
" <td>14</td>\n",
" <td>68500.0</td>\n",
" <td>69664.285714</td>\n",
" <td>33778.136013</td>\n",
" <td>10.214286</td>\n",
" </tr>\n",
" <tr>\n",
" <th>11</th>\n",
" <td>Google Data Engineer</td>\n",
" <td>16</td>\n",
" <td>65000.0</td>\n",
" <td>64750.000000</td>\n",
" <td>21989.391382</td>\n",
" <td>9.000000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>Google Mobile Web Specialist</td>\n",
" <td>3</td>\n",
" <td>60000.0</td>\n",
" <td>66000.000000</td>\n",
" <td>57236.352085</td>\n",
" <td>15.000000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>AWS Solution Architect</td>\n",
" <td>39</td>\n",
" <td>57000.0</td>\n",
" <td>60207.435897</td>\n",
" <td>21183.553665</td>\n",
" <td>10.000000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>Business Analyst (CCBA o CBAP)</td>\n",
" <td>11</td>\n",
" <td>56000.0</td>\n",
" <td>66545.454545</td>\n",
" <td>22196.232277</td>\n",
" <td>20.181818</td>\n",
" </tr>\n",
" <tr>\n",
" <th>23</th>\n",
" <td>Seguridad (Ethical Hacker, CISM, CISSP, CompTIA)</td>\n",
" <td>17</td>\n",
" <td>56000.0</td>\n",
" <td>62382.352941</td>\n",
" <td>58436.805988</td>\n",
" <td>14.705882</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>AWS Developer</td>\n",
" <td>40</td>\n",
" <td>56000.0</td>\n",
" <td>61823.550000</td>\n",
" <td>35050.112045</td>\n",
" <td>10.425000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>19</th>\n",
" <td>PMP</td>\n",
" <td>59</td>\n",
" <td>55000.0</td>\n",
" <td>57675.254237</td>\n",
" <td>25736.333994</td>\n",
" <td>18.559322</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>Enterprise Architect (SEI, IASA, Togaf, Zachman)</td>\n",
" <td>12</td>\n",
" <td>55000.0</td>\n",
" <td>74500.000000</td>\n",
" <td>58669.335339</td>\n",
" <td>18.750000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>22</th>\n",
" <td>Six Sigma</td>\n",
" <td>41</td>\n",
" <td>55000.0</td>\n",
" <td>57224.146341</td>\n",
" <td>33297.418892</td>\n",
" <td>15.536585</td>\n",
" </tr>\n",
" <tr>\n",
" <th>12</th>\n",
" <td>ITIL Practitioner</td>\n",
" <td>45</td>\n",
" <td>55000.0</td>\n",
" <td>58457.777778</td>\n",
" <td>31039.911909</td>\n",
" <td>17.200000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>24</th>\n",
" <td>Testing Foundation (CTFL, ASTQB)</td>\n",
" <td>27</td>\n",
" <td>52000.0</td>\n",
" <td>52268.518519</td>\n",
" <td>33658.754571</td>\n",
" <td>14.888889</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Agile Certified Practitioner</td>\n",
" <td>66</td>\n",
" <td>51700.0</td>\n",
" <td>60739.393939</td>\n",
" <td>46510.276379</td>\n",
" <td>12.621212</td>\n",
" </tr>\n",
" <tr>\n",
" <th>21</th>\n",
" <td>Scrum Master</td>\n",
" <td>203</td>\n",
" <td>50000.0</td>\n",
" <td>52607.645320</td>\n",
" <td>31189.185992</td>\n",
" <td>13.694581</td>\n",
" </tr>\n",
" <tr>\n",
" <th>14</th>\n",
" <td>Java</td>\n",
" <td>165</td>\n",
" <td>49500.0</td>\n",
" <td>55312.600000</td>\n",
" <td>37565.833977</td>\n",
" <td>11.781818</td>\n",
" </tr>\n",
" <tr>\n",
" <th>13</th>\n",
" <td>ITIL Intermediate</td>\n",
" <td>36</td>\n",
" <td>47500.0</td>\n",
" <td>45722.222222</td>\n",
" <td>19212.334001</td>\n",
" <td>16.222222</td>\n",
" </tr>\n",
" <tr>\n",
" <th>20</th>\n",
" <td>SAP (cualquier módulo)</td>\n",
" <td>24</td>\n",
" <td>47000.0</td>\n",
" <td>46180.416667</td>\n",
" <td>22305.943540</td>\n",
" <td>14.583333</td>\n",
" </tr>\n",
" <tr>\n",
" <th>18</th>\n",
" <td>Oracle DBA</td>\n",
" <td>19</td>\n",
" <td>45000.0</td>\n",
" <td>48981.473684</td>\n",
" <td>29823.083326</td>\n",
" <td>18.315789</td>\n",
" </tr>\n",
" <tr>\n",
" <th>16</th>\n",
" <td>Microsoft Associate</td>\n",
" <td>63</td>\n",
" <td>45000.0</td>\n",
" <td>52417.746032</td>\n",
" <td>33982.873538</td>\n",
" <td>13.952381</td>\n",
" </tr>\n",
" <tr>\n",
" <th>15</th>\n",
" <td>Linux</td>\n",
" <td>43</td>\n",
" <td>45000.0</td>\n",
" <td>49974.744186</td>\n",
" <td>38919.161632</td>\n",
" <td>12.976744</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>Android Developer</td>\n",
" <td>26</td>\n",
" <td>43500.0</td>\n",
" <td>50419.192308</td>\n",
" <td>31226.346071</td>\n",
" <td>8.500000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>17</th>\n",
" <td>Microsoft Expert</td>\n",
" <td>39</td>\n",
" <td>43000.0</td>\n",
" <td>47154.205128</td>\n",
" <td>40500.260560</td>\n",
" <td>14.179487</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>COBIT</td>\n",
" <td>21</td>\n",
" <td>43000.0</td>\n",
" <td>53271.428571</td>\n",
" <td>23653.480565</td>\n",
" <td>16.428571</td>\n",
" </tr>\n",
" <tr>\n",
" <th>25</th>\n",
" <td>Testing Advanced (CTAL)</td>\n",
" <td>6</td>\n",
" <td>35000.0</td>\n",
" <td>37000.000000</td>\n",
" <td>16970.562748</td>\n",
" <td>20.000000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>Cisco Networking Professional</td>\n",
" <td>26</td>\n",
" <td>30000.0</td>\n",
" <td>37508.230769</td>\n",
" <td>29419.676160</td>\n",
" <td>7.692308</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>Enterprise Governance (CGEIT)</td>\n",
" <td>0</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Certificacion ... exp\n",
"9 Google Cloud Architect ... 10.214286\n",
"11 Google Data Engineer ... 9.000000\n",
"10 Google Mobile Web Specialist ... 15.000000\n",
"2 AWS Solution Architect ... 10.000000\n",
"3 Business Analyst (CCBA o CBAP) ... 20.181818\n",
"23 Seguridad (Ethical Hacker, CISM, CISSP, CompTIA) ... 14.705882\n",
"1 AWS Developer ... 10.425000\n",
"19 PMP ... 18.559322\n",
"6 Enterprise Architect (SEI, IASA, Togaf, Zachman) ... 18.750000\n",
"22 Six Sigma ... 15.536585\n",
"12 ITIL Practitioner ... 17.200000\n",
"24 Testing Foundation (CTFL, ASTQB) ... 14.888889\n",
"0 Agile Certified Practitioner ... 12.621212\n",
"21 Scrum Master ... 13.694581\n",
"14 Java ... 11.781818\n",
"13 ITIL Intermediate ... 16.222222\n",
"20 SAP (cualquier módulo) ... 14.583333\n",
"18 Oracle DBA ... 18.315789\n",
"16 Microsoft Associate ... 13.952381\n",
"15 Linux ... 12.976744\n",
"8 Android Developer ... 8.500000\n",
"17 Microsoft Expert ... 14.179487\n",
"5 COBIT ... 16.428571\n",
"25 Testing Advanced (CTAL) ... 20.000000\n",
"4 Cisco Networking Professional ... 7.692308\n",
"7 Enterprise Governance (CGEIT) ... NaN\n",
"\n",
"[26 rows x 6 columns]"
]
},
"metadata": {
"tags": []
},
"execution_count": 69
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "eJAdBc0Y1pY4"
},
"source": [
"## Infraestructura"
]
},
{
"cell_type": "code",
"metadata": {
"id": "LKJN_gRa1pY4",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 314
},
"outputId": "e63ac915-e2da-4a52-ee61-91072a87bfdf"
},
"source": [
"# Inicializamos nuestra lista maestra\n",
"item_list = []\n",
"# URL del catálogo\n",
"url = 'https://raw.githubusercontent.com/softwareguru/salarios-notebook/main/infra_options.csv'\n",
"reader = get_remote_csv_reader(url)\n",
"\n",
"for row in reader:\n",
" item_key = \"infra_\"+row['key']\n",
" # Por cada elemento en la lista agregamos un renglon con el nombre de la categoria y estadisticas agregadas.\n",
" item_list.append([row['name'], df[(df[item_key]==\"Y\")][\"salarymx\"].count(), df[(df[item_key]==\"Y\")][\"salarymx\"].median(), df[(df[item_key]==\"Y\")][\"salarymx\"].mean(), df[(df[item_key]==\"Y\")][\"salarymx\"].std(), df[(df[item_key]==\"Y\")][\"experience\"].mean()])\n",
"\n",
"# Una vez que tenemos la lista maestra completa, creamos un dataframe indicando el nombre de las columnas.\n",
"itemdf = pd.DataFrame(item_list, columns = ['Infra', 'n', 'mediana','media', 'std', 'exp'])\n",
"# Agregamos una columna de popularidad que se calcule en base a un valor amortiguado del número de observaciones. \n",
"itemdf.sort_values(by=['mediana'], ascending=False).head(30)"
],
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Infra</th>\n",
" <th>n</th>\n",
" <th>mediana</th>\n",
" <th>media</th>\n",
" <th>std</th>\n",
" <th>exp</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>Terraform</td>\n",
" <td>40</td>\n",
" <td>70500.0</td>\n",
" <td>69652.125000</td>\n",
" <td>28059.282912</td>\n",
" <td>8.800000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>Kubernetes</td>\n",
" <td>37</td>\n",
" <td>70000.0</td>\n",
" <td>64972.972973</td>\n",
" <td>33806.168476</td>\n",
" <td>8.108108</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>Ansible</td>\n",
" <td>27</td>\n",
" <td>65000.0</td>\n",
" <td>66196.777778</td>\n",
" <td>31890.878421</td>\n",
" <td>8.666667</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>Chef</td>\n",
" <td>6</td>\n",
" <td>64450.0</td>\n",
" <td>62316.666667</td>\n",
" <td>23117.129291</td>\n",
" <td>12.000000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>Puppet</td>\n",
" <td>5</td>\n",
" <td>60000.0</td>\n",
" <td>73622.600000</td>\n",
" <td>41980.223365</td>\n",
" <td>8.400000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Docker</td>\n",
" <td>83</td>\n",
" <td>55000.0</td>\n",
" <td>59755.614458</td>\n",
" <td>33203.437231</td>\n",
" <td>8.192771</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>OpenStack</td>\n",
" <td>4</td>\n",
" <td>52500.0</td>\n",
" <td>52750.000000</td>\n",
" <td>3201.562119</td>\n",
" <td>9.500000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>OpenShift</td>\n",
" <td>6</td>\n",
" <td>46500.0</td>\n",
" <td>52633.333333</td>\n",
" <td>32259.055576</td>\n",
" <td>7.833333</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>VMware vCloud / vCenter</td>\n",
" <td>15</td>\n",
" <td>41000.0</td>\n",
" <td>39946.666667</td>\n",
" <td>16627.209484</td>\n",
" <td>13.466667</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Infra n mediana media std exp\n",
"5 Terraform 40 70500.0 69652.125000 28059.282912 8.800000\n",
"2 Kubernetes 37 70000.0 64972.972973 33806.168476 8.108108\n",
"1 Ansible 27 65000.0 66196.777778 31890.878421 8.666667\n",
"3 Chef 6 64450.0 62316.666667 23117.129291 12.000000\n",
"4 Puppet 5 60000.0 73622.600000 41980.223365 8.400000\n",
"0 Docker 83 55000.0 59755.614458 33203.437231 8.192771\n",
"6 OpenStack 4 52500.0 52750.000000 3201.562119 9.500000\n",
"7 OpenShift 6 46500.0 52633.333333 32259.055576 7.833333\n",
"8 VMware vCloud / vCenter 15 41000.0 39946.666667 16627.209484 13.466667"
]
},
"metadata": {
"tags": []
},
"execution_count": 70
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "zhlesiKR1pY5"
},
"source": [
"## Actividad"
]
},
{
"cell_type": "code",
"metadata": {
"id": "18xhz4B61pY5",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 728
},
"outputId": "627793ee-fcba-48ca-ab39-d80b7c5cc200"
},
"source": [
"# Inicializamos nuestra lista maestra\n",
"item_list = []\n",
"# URL del catálogo\n",
"url = 'https://raw.githubusercontent.com/softwareguru/salarios-notebook/main/activity_options.csv'\n",
"reader = get_remote_csv_reader(url)\n",
"\n",
"for row in reader:\n",
" item_key = \"act_\"+row['key']\n",
" item_list.append([row['name'], df[(df[item_key]==\"Y\")][\"salarymx\"].count(), df[(df[item_key]==\"Y\")][\"salarymx\"].median(), df[(df[item_key]==\"Y\")][\"salarymx\"].mean(), df[(df[item_key]==\"Y\")][\"salarymx\"].std()])\n",
"\n",
"# Una vez que tenemos la lista maestra completa, creamos un dataframe indicando el nombre de las columnas.\n",
"act_df = pd.DataFrame(item_list, columns = ['Actividad', 'n', 'mediana', 'mean', 'std'])\n",
"act_df.sort_values(by=['mediana'], ascending=False).head(30)"
],
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Actividad</th>\n",
" <th>n</th>\n",
" <th>mediana</th>\n",
" <th>mean</th>\n",
" <th>std</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>Dirección / Estrategia</td>\n",
" <td>107</td>\n",
" <td>64000.0</td>\n",
" <td>71473.439252</td>\n",
" <td>42205.823219</td>\n",
" </tr>\n",
" <tr>\n",
" <th>17</th>\n",
" <td>Preventa / Tech sales</td>\n",
" <td>24</td>\n",
" <td>60000.0</td>\n",
" <td>70875.000000</td>\n",
" <td>45488.949924</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>Arquitectura y diseño de sistemas</td>\n",
" <td>396</td>\n",
" <td>55000.0</td>\n",
" <td>61482.171717</td>\n",
" <td>38916.502292</td>\n",
" </tr>\n",
" <tr>\n",
" <th>21</th>\n",
" <td>Venta y desarrollo de negocios</td>\n",
" <td>22</td>\n",
" <td>52500.0</td>\n",
" <td>69045.454545</td>\n",
" <td>52469.925420</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>Gestión de infraestructura (SysOps, DevOps)</td>\n",
" <td>124</td>\n",
" <td>50500.0</td>\n",
" <td>55724.645161</td>\n",
" <td>31477.826368</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>Coaching y mejora de procesos</td>\n",
" <td>104</td>\n",
" <td>50000.0</td>\n",
" <td>56376.548077</td>\n",
" <td>36772.411326</td>\n",
" </tr>\n",
" <tr>\n",
" <th>16</th>\n",
" <td>Project management / Coordinación</td>\n",
" <td>228</td>\n",
" <td>48000.0</td>\n",
" <td>55390.587719</td>\n",
" <td>38169.530734</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>Ingeniería de datos</td>\n",
" <td>71</td>\n",
" <td>45000.0</td>\n",
" <td>51119.718310</td>\n",
" <td>28823.906842</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>Ciencia de datos</td>\n",
" <td>54</td>\n",
" <td>43150.0</td>\n",
" <td>48506.444444</td>\n",
" <td>24386.976675</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>Capacitación y evangelización</td>\n",
" <td>69</td>\n",
" <td>43000.0</td>\n",
" <td>45995.652174</td>\n",
" <td>36260.213307</td>\n",
" </tr>\n",
" <tr>\n",
" <th>18</th>\n",
" <td>Seguridad de información</td>\n",
" <td>54</td>\n",
" <td>43000.0</td>\n",
" <td>43111.555556</td>\n",
" <td>27284.270320</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>Consultoría de negocio</td>\n",
" <td>82</td>\n",
" <td>40000.0</td>\n",
" <td>46074.060976</td>\n",
" <td>23789.387866</td>\n",
" </tr>\n",
" <tr>\n",
" <th>14</th>\n",
" <td>Programación back-end (procesamiento, lógica, ...</td>\n",
" <td>771</td>\n",
" <td>40000.0</td>\n",
" <td>46945.691310</td>\n",
" <td>35530.930217</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>Business Intelligence</td>\n",
" <td>51</td>\n",
" <td>40000.0</td>\n",
" <td>44921.176471</td>\n",
" <td>25582.658396</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>Análisis de requerimientos</td>\n",
" <td>396</td>\n",
" <td>38000.0</td>\n",
" <td>44234.603535</td>\n",
" <td>30572.962211</td>\n",
" </tr>\n",
" <tr>\n",
" <th>20</th>\n",
" <td>Testing</td>\n",
" <td>159</td>\n",
" <td>37400.0</td>\n",
" <td>41905.251572</td>\n",
" <td>32399.830702</td>\n",
" </tr>\n",
" <tr>\n",
" <th>13</th>\n",
" <td>Implantación de sistemas empresariales (ERPs y...</td>\n",
" <td>63</td>\n",
" <td>35000.0</td>\n",
" <td>38671.111111</td>\n",
" <td>23308.020502</td>\n",
" </tr>\n",
" <tr>\n",
" <th>15</th>\n",
" <td>Programación front-end</td>\n",
" <td>534</td>\n",
" <td>35000.0</td>\n",
" <td>43771.874532</td>\n",
" <td>35448.139572</td>\n",
" </tr>\n",
" <tr>\n",
" <th>12</th>\n",
" <td>User Experience Design</td>\n",
" <td>70</td>\n",
" <td>28500.0</td>\n",
" <td>35468.471429</td>\n",
" <td>29206.091246</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Administración de bases de datos</td>\n",
" <td>205</td>\n",
" <td>28000.0</td>\n",
" <td>37196.112195</td>\n",
" <td>29763.170725</td>\n",
" </tr>\n",
" <tr>\n",
" <th>22</th>\n",
" <td>Documentación / Technical writing</td>\n",
" <td>123</td>\n",
" <td>28000.0</td>\n",
" <td>35041.414634</td>\n",
" <td>25660.750606</td>\n",
" </tr>\n",
" <tr>\n",
" <th>19</th>\n",
" <td>Soporte técnico</td>\n",
" <td>122</td>\n",
" <td>24500.0</td>\n",
" <td>31613.622951</td>\n",
" <td>26817.801296</td>\n",
" </tr>\n",
" <tr>\n",
" <th>11</th>\n",
" <td>Docencia</td>\n",
" <td>45</td>\n",
" <td>22500.0</td>\n",
" <td>29222.222222</td>\n",
" <td>18918.940592</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Actividad ... std\n",
"10 Dirección / Estrategia ... 42205.823219\n",
"17 Preventa / Tech sales ... 45488.949924\n",
"2 Arquitectura y diseño de sistemas ... 38916.502292\n",
"21 Venta y desarrollo de negocios ... 52469.925420\n",
"6 Gestión de infraestructura (SysOps, DevOps) ... 31477.826368\n",
"8 Coaching y mejora de procesos ... 36772.411326\n",
"16 Project management / Coordinación ... 38169.530734\n",
"7 Ingeniería de datos ... 28823.906842\n",
"5 Ciencia de datos ... 24386.976675\n",
"4 Capacitación y evangelización ... 36260.213307\n",
"18 Seguridad de información ... 27284.270320\n",
"9 Consultoría de negocio ... 23789.387866\n",
"14 Programación back-end (procesamiento, lógica, ... ... 35530.930217\n",
"3 Business Intelligence ... 25582.658396\n",
"1 Análisis de requerimientos ... 30572.962211\n",
"20 Testing ... 32399.830702\n",
"13 Implantación de sistemas empresariales (ERPs y... ... 23308.020502\n",
"15 Programación front-end ... 35448.139572\n",
"12 User Experience Design ... 29206.091246\n",
"0 Administración de bases de datos ... 29763.170725\n",
"22 Documentación / Technical writing ... 25660.750606\n",
"19 Soporte técnico ... 26817.801296\n",
"11 Docencia ... 18918.940592\n",
"\n",
"[23 rows x 5 columns]"
]
},
"metadata": {
"tags": []
},
"execution_count": 72
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "HEazFlPO1pY5"
},
"source": [
"## Estudios"
]
},
{
"cell_type": "code",
"metadata": {
"id": "sXwyP1HL1pY5",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 314
},
"outputId": "1e3111ea-ca87-4137-85b7-3bf7d5cc0046"
},
"source": [
"educacion = df.groupby(\"education\")[\"salarymx\"].agg(['count', 'median', 'mean', 'std']).sort_values(by=['median'], ascending=False)\n",
"educacion['mean'] = round(educacion['mean']).astype(int)\n",
"educacion"
],
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>count</th>\n",
" <th>median</th>\n",
" <th>mean</th>\n",
" <th>std</th>\n",
" </tr>\n",
" <tr>\n",
" <th>education</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>phd</th>\n",
" <td>20</td>\n",
" <td>61000.0</td>\n",
" <td>57695</td>\n",
" <td>29410.300290</td>\n",
" </tr>\n",
" <tr>\n",
" <th>maestria</th>\n",
" <td>268</td>\n",
" <td>48250.0</td>\n",
" <td>55962</td>\n",
" <td>34761.916126</td>\n",
" </tr>\n",
" <tr>\n",
" <th>posgrado</th>\n",
" <td>51</td>\n",
" <td>47000.0</td>\n",
" <td>53096</td>\n",
" <td>27721.141391</td>\n",
" </tr>\n",
" <tr>\n",
" <th>secundaria</th>\n",
" <td>2</td>\n",
" <td>46200.0</td>\n",
" <td>46200</td>\n",
" <td>33658.282784</td>\n",
" </tr>\n",
" <tr>\n",
" <th>prepa</th>\n",
" <td>32</td>\n",
" <td>40000.0</td>\n",
" <td>53220</td>\n",
" <td>42662.232787</td>\n",
" </tr>\n",
" <tr>\n",
" <th>universidad</th>\n",
" <td>768</td>\n",
" <td>40000.0</td>\n",
" <td>46242</td>\n",
" <td>34229.199975</td>\n",
" </tr>\n",
" <tr>\n",
" <th>pasante</th>\n",
" <td>343</td>\n",
" <td>35000.0</td>\n",
" <td>42287</td>\n",
" <td>34636.096976</td>\n",
" </tr>\n",
" <tr>\n",
" <th>tecnica</th>\n",
" <td>32</td>\n",
" <td>30056.5</td>\n",
" <td>36038</td>\n",
" <td>24581.097372</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" count median mean std\n",
"education \n",
"phd 20 61000.0 57695 29410.300290\n",
"maestria 268 48250.0 55962 34761.916126\n",
"posgrado 51 47000.0 53096 27721.141391\n",
"secundaria 2 46200.0 46200 33658.282784\n",
"prepa 32 40000.0 53220 42662.232787\n",
"universidad 768 40000.0 46242 34229.199975\n",
"pasante 343 35000.0 42287 34636.096976\n",
"tecnica 32 30056.5 36038 24581.097372"
]
},
"metadata": {
"tags": []
},
"execution_count": 50
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "rmmGo1s_1pY6"
},
"source": [
"## ¿Dónde aprendiste a programar?"
]
},
{
"cell_type": "code",
"metadata": {
"scrolled": true,
"id": "pWQ7tdrg1pY6",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 225
},
"outputId": "3b670f19-c2b2-4b97-f50e-d3d90e0e37fc"
},
"source": [
"edutype = df.groupby(\"edutype\")[\"salarymx\"].agg(['count', 'median', 'mean', 'std']).sort_values(by=['median'], ascending=False)\n",
"edutype"
],
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>count</th>\n",
" <th>median</th>\n",
" <th>mean</th>\n",
" <th>std</th>\n",
" </tr>\n",
" <tr>\n",
" <th>edutype</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>autodidacta</th>\n",
" <td>238</td>\n",
" <td>46000</td>\n",
" <td>56943.936975</td>\n",
" <td>43008.808824</td>\n",
" </tr>\n",
" <tr>\n",
" <th>escuela</th>\n",
" <td>949</td>\n",
" <td>41140</td>\n",
" <td>46766.448894</td>\n",
" <td>32437.280229</td>\n",
" </tr>\n",
" <tr>\n",
" <th>trabajo</th>\n",
" <td>185</td>\n",
" <td>40000</td>\n",
" <td>48028.362162</td>\n",
" <td>34684.276118</td>\n",
" </tr>\n",
" <tr>\n",
" <th>online</th>\n",
" <td>98</td>\n",
" <td>32500</td>\n",
" <td>37324.765306</td>\n",
" <td>30538.807949</td>\n",
" </tr>\n",
" <tr>\n",
" <th>bootcamp</th>\n",
" <td>46</td>\n",
" <td>29500</td>\n",
" <td>29345.978261</td>\n",
" <td>12114.418114</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" count median mean std\n",
"edutype \n",
"autodidacta 238 46000 56943.936975 43008.808824\n",
"escuela 949 41140 46766.448894 32437.280229\n",
"trabajo 185 40000 48028.362162 34684.276118\n",
"online 98 32500 37324.765306 30538.807949\n",
"bootcamp 46 29500 29345.978261 12114.418114"
]
},
"metadata": {
"tags": []
},
"execution_count": 51
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "qI7JnlCi1pY6"
},
"source": [
"Vemos que cursos online y bootcamps aparecen con los salarios más bajos. Pero eso puede ser engañoso, porque son opciones relativamente recientes y por lo tanto la gente que aprendió de esta manera no tiene tanta experiencia (que junto con el nivel de inglés es el factor que más influye en el salario). Así que ahora tomemos en cuenta solamente a los que tienen 5 años o menos de experiencia."
]
},
{
"cell_type": "code",
"metadata": {
"id": "093SKlon1pY6",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 225
},
"outputId": "79dee580-2560-44bb-b0c5-e114dbf50644"
},
"source": [
"edutype = df[(df['experience']<=5)].groupby(\"edutype\")[\"salarymx\"].agg(['count', 'median', 'mean', 'std']).sort_values(by=['median'], ascending=False)\n",
"edutype"
],
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>count</th>\n",
" <th>median</th>\n",
" <th>mean</th>\n",
" <th>std</th>\n",
" </tr>\n",
" <tr>\n",
" <th>edutype</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>autodidacta</th>\n",
" <td>67</td>\n",
" <td>31000</td>\n",
" <td>36128.552239</td>\n",
" <td>28860.789052</td>\n",
" </tr>\n",
" <tr>\n",
" <th>bootcamp</th>\n",
" <td>33</td>\n",
" <td>28000</td>\n",
" <td>28461.060606</td>\n",
" <td>11207.826350</td>\n",
" </tr>\n",
" <tr>\n",
" <th>escuela</th>\n",
" <td>338</td>\n",
" <td>25000</td>\n",
" <td>29682.535503</td>\n",
" <td>21080.730388</td>\n",
" </tr>\n",
" <tr>\n",
" <th>trabajo</th>\n",
" <td>54</td>\n",
" <td>24050</td>\n",
" <td>30588.814815</td>\n",
" <td>23947.504719</td>\n",
" </tr>\n",
" <tr>\n",
" <th>online</th>\n",
" <td>55</td>\n",
" <td>22000</td>\n",
" <td>30668.800000</td>\n",
" <td>28033.391477</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" count median mean std\n",
"edutype \n",
"autodidacta 67 31000 36128.552239 28860.789052\n",
"bootcamp 33 28000 28461.060606 11207.826350\n",
"escuela 338 25000 29682.535503 21080.730388\n",
"trabajo 54 24050 30588.814815 23947.504719\n",
"online 55 22000 30668.800000 28033.391477"
]
},
"metadata": {
"tags": []
},
"execution_count": 52
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "QHdtnxpL1pY6"
},
"source": [
"Podemos ver que las cosas se emparejan mucho más. Incluso podemos decir que donde aprendiste a programar no es un factor significativo para tu salario. En otras palbras, lo que importa es lo que sabes, no como lo aprendiste.\n",
"\n",
"Aprovechando que estamos en esto, vamos a ver si está cambiando la donde aprenden a programar las personas. Para ello, haremos un cruce de donde aprendieron vs años de experiencia."
]
},
{
"cell_type": "code",
"metadata": {
"id": "3nzH7VR21pY7",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "01d450b3-1e4f-4368-d5d8-dc23c344917f"
},
"source": [
"exp_bin = df.groupby(['edutype','exp_bin'])['salarymx'].agg(['median', 'count']).fillna(0)\n",
"edutype_pct = exp_bin.groupby(level=1)['count'].apply(lambda x: x / float(x.sum()))\n",
"edutype_pct.head(20)"
],
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"edutype exp_bin \n",
"autodidacta (-0.1, 2.0] 0.089474\n",
" (2.0, 4.0] 0.139423\n",
" (4.0, 6.0] 0.148760\n",
" (6.0, 8.0] 0.174419\n",
" (8.0, 10.0] 0.186667\n",
" (10.0, 14.0] 0.179894\n",
" (14.0, 20.0] 0.175355\n",
" (20.0, 40.0] 0.175325\n",
"bootcamp (-0.1, 2.0] 0.084211\n",
" (2.0, 4.0] 0.067308\n",
" (4.0, 6.0] 0.016529\n",
" (6.0, 8.0] 0.005814\n",
" (8.0, 10.0] 0.020000\n",
" (10.0, 14.0] 0.026455\n",
" (14.0, 20.0] 0.009479\n",
" (20.0, 40.0] 0.006494\n",
"escuela (-0.1, 2.0] 0.621053\n",
" (2.0, 4.0] 0.596154\n",
" (4.0, 6.0] 0.619835\n",
" (6.0, 8.0] 0.610465\n",
"Name: count, dtype: float64"
]
},
"metadata": {
"tags": []
},
"execution_count": 54
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "Nj2OZZgT1pY7",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 284
},
"outputId": "b796fc0b-038e-4514-a12b-a95792c81206"
},
"source": [
"data = {\n",
" 'exp': exp_labels,\n",
" 'escuela' : list(edutype_pct.xs('escuela')),\n",
" 'autodidacta': list(edutype_pct.xs('autodidacta')),\n",
" 'trabajo' : list(edutype_pct.xs('trabajo')),\n",
" 'online' : list(edutype_pct.xs('online')),\n",
" 'bootcamp' : list(edutype_pct.xs('bootcamp'))\n",
"}\n",
"\n",
"edudf = pd.DataFrame(data)\n",
"edudf.sort_index(ascending=False, inplace=True)\n",
"edudf.head(20)"
],
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>exp</th>\n",
" <th>escuela</th>\n",
" <th>autodidacta</th>\n",
" <th>trabajo</th>\n",
" <th>online</th>\n",
" <th>bootcamp</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>20+</td>\n",
" <td>0.707792</td>\n",
" <td>0.175325</td>\n",
" <td>0.097403</td>\n",
" <td>0.012987</td>\n",
" <td>0.006494</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>15-20</td>\n",
" <td>0.630332</td>\n",
" <td>0.175355</td>\n",
" <td>0.156398</td>\n",
" <td>0.028436</td>\n",
" <td>0.009479</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>11-14</td>\n",
" <td>0.587302</td>\n",
" <td>0.179894</td>\n",
" <td>0.169312</td>\n",
" <td>0.037037</td>\n",
" <td>0.026455</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>9-10</td>\n",
" <td>0.660000</td>\n",
" <td>0.186667</td>\n",
" <td>0.106667</td>\n",
" <td>0.026667</td>\n",
" <td>0.020000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>7-8</td>\n",
" <td>0.610465</td>\n",
" <td>0.174419</td>\n",
" <td>0.139535</td>\n",
" <td>0.069767</td>\n",
" <td>0.005814</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>5-6</td>\n",
" <td>0.619835</td>\n",
" <td>0.148760</td>\n",
" <td>0.111570</td>\n",
" <td>0.103306</td>\n",
" <td>0.016529</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>3-4</td>\n",
" <td>0.596154</td>\n",
" <td>0.139423</td>\n",
" <td>0.105769</td>\n",
" <td>0.091346</td>\n",
" <td>0.067308</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>0-2</td>\n",
" <td>0.621053</td>\n",
" <td>0.089474</td>\n",
" <td>0.084211</td>\n",
" <td>0.121053</td>\n",
" <td>0.084211</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" exp escuela autodidacta trabajo online bootcamp\n",
"7 20+ 0.707792 0.175325 0.097403 0.012987 0.006494\n",
"6 15-20 0.630332 0.175355 0.156398 0.028436 0.009479\n",
"5 11-14 0.587302 0.179894 0.169312 0.037037 0.026455\n",
"4 9-10 0.660000 0.186667 0.106667 0.026667 0.020000\n",
"3 7-8 0.610465 0.174419 0.139535 0.069767 0.005814\n",
"2 5-6 0.619835 0.148760 0.111570 0.103306 0.016529\n",
"1 3-4 0.596154 0.139423 0.105769 0.091346 0.067308\n",
"0 0-2 0.621053 0.089474 0.084211 0.121053 0.084211"
]
},
"metadata": {
"tags": []
},
"execution_count": 55
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "AR43eLCx1pY7",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 417
},
"outputId": "6e751d19-6228-4b46-f2ab-82ce27cdb243"
},
"source": [
"\n",
"\n",
"src = ColumnDataSource(edudf)\n",
"col_names = src.column_names\n",
"\n",
"p = figure(x_range=exp_labels[::-1], plot_height=400, plot_width=600)\n",
"\n",
"for col_name, color in zip(list(edudf.columns), Dark2[6]):\n",
" if col_name == 'exp':\n",
" continue\n",
"\n",
" p.add_tools(HoverTool(\n",
" renderers= [p.line('exp', col_name, source=src, color=color, legend_label=col_name)],\n",
" tooltips=[\n",
" ('Formación', f'{col_name}'),\n",
" ('Pct', '@'+col_name+'{0%}')\n",
" ]\n",
" ))\n",
"\n",
"p.title.text = 'Evolución de donde aprendemos a programar'\n",
"p.xaxis.axis_label = 'Experiencia (años)'\n",
"p.yaxis.axis_label = 'Porcentaje'\n",
"p.yaxis.formatter = NumeralTickFormatter(format='0%') \n",
"p.legend.location = (400,120)\n",
" \n",
"show(p)\n"
],
"execution_count": null,
"outputs": [
{
"output_type": "display_data",
"data": {
"application/javascript": [
"\n",
"(function(root) {\n",
" function now() {\n",
" return new Date();\n",
" }\n",
"\n",
" var force = true;\n",
"\n",
" if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n",
" root._bokeh_onload_callbacks = [];\n",
" root._bokeh_is_loading = undefined;\n",
" }\n",
"\n",
" var JS_MIME_TYPE = 'application/javascript';\n",
" var HTML_MIME_TYPE = 'text/html';\n",
" var EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n",
" var CLASS_NAME = 'output_bokeh rendered_html';\n",
"\n",
" /**\n",
" * Render data to the DOM node\n",
" */\n",
" function render(props, node) {\n",
" var script = document.createElement(\"script\");\n",
" node.appendChild(script);\n",
" }\n",
"\n",
" /**\n",
" * Handle when an output is cleared or removed\n",
" */\n",
" function handleClearOutput(event, handle) {\n",
" var cell = handle.cell;\n",
"\n",
" var id = cell.output_area._bokeh_element_id;\n",
" var server_id = cell.output_area._bokeh_server_id;\n",
" // Clean up Bokeh references\n",
" if (id != null && id in Bokeh.index) {\n",
" Bokeh.index[id].model.document.clear();\n",
" delete Bokeh.index[id];\n",
" }\n",
"\n",
" if (server_id !== undefined) {\n",
" // Clean up Bokeh references\n",
" var cmd = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n",
" cell.notebook.kernel.execute(cmd, {\n",
" iopub: {\n",
" output: function(msg) {\n",
" var id = msg.content.text.trim();\n",
" if (id in Bokeh.index) {\n",
" Bokeh.index[id].model.document.clear();\n",
" delete Bokeh.index[id];\n",
" }\n",
" }\n",
" }\n",
" });\n",
" // Destroy server and session\n",
" var cmd = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n",
" cell.notebook.kernel.execute(cmd);\n",
" }\n",
" }\n",
"\n",
" /**\n",
" * Handle when a new output is added\n",
" */\n",
" function handleAddOutput(event, handle) {\n",
" var output_area = handle.output_area;\n",
" var output = handle.output;\n",
"\n",
" // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n",
" if ((output.output_type != \"display_data\") || (!output.data.hasOwnProperty(EXEC_MIME_TYPE))) {\n",
" return\n",
" }\n",
"\n",
" var toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n",
"\n",
" if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n",
" toinsert[toinsert.length - 1].firstChild.textContent = output.data[JS_MIME_TYPE];\n",
" // store reference to embed id on output_area\n",
" output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n",
" }\n",
" if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n",
" var bk_div = document.createElement(\"div\");\n",
" bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n",
" var script_attrs = bk_div.children[0].attributes;\n",
" for (var i = 0; i < script_attrs.length; i++) {\n",
" toinsert[toinsert.length - 1].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n",
" toinsert[toinsert.length - 1].firstChild.textContent = bk_div.children[0].textContent\n",
" }\n",
" // store reference to server id on output_area\n",
" output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n",
" }\n",
" }\n",
"\n",
" function register_renderer(events, OutputArea) {\n",
"\n",
" function append_mime(data, metadata, element) {\n",
" // create a DOM node to render to\n",
" var toinsert = this.create_output_subarea(\n",
" metadata,\n",
" CLASS_NAME,\n",
" EXEC_MIME_TYPE\n",
" );\n",
" this.keyboard_manager.register_events(toinsert);\n",
" // Render to node\n",
" var props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n",
" render(props, toinsert[toinsert.length - 1]);\n",
" element.append(toinsert);\n",
" return toinsert\n",
" }\n",
"\n",
" /* Handle when an output is cleared or removed */\n",
" events.on('clear_output.CodeCell', handleClearOutput);\n",
" events.on('delete.Cell', handleClearOutput);\n",
"\n",
" /* Handle when a new output is added */\n",
" events.on('output_added.OutputArea', handleAddOutput);\n",
"\n",
" /**\n",
" * Register the mime type and append_mime function with output_area\n",
" */\n",
" OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n",
" /* Is output safe? */\n",
" safe: true,\n",
" /* Index of renderer in `output_area.display_order` */\n",
" index: 0\n",
" });\n",
" }\n",
"\n",
" // register the mime type if in Jupyter Notebook environment and previously unregistered\n",
" if (root.Jupyter !== undefined) {\n",
" var events = require('base/js/events');\n",
" var OutputArea = require('notebook/js/outputarea').OutputArea;\n",
"\n",
" if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n",
" register_renderer(events, OutputArea);\n",
" }\n",
" }\n",
"\n",
" \n",
" if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n",
" root._bokeh_timeout = Date.now() + 5000;\n",
" root._bokeh_failed_load = false;\n",
" }\n",
"\n",
" var NB_LOAD_WARNING = {'data': {'text/html':\n",
" \"<div style='background-color: #fdd'>\\n\"+\n",
" \"<p>\\n\"+\n",
" \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n",
" \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n",
" \"</p>\\n\"+\n",
" \"<ul>\\n\"+\n",
" \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n",
" \"<li>use INLINE resources instead, as so:</li>\\n\"+\n",
" \"</ul>\\n\"+\n",
" \"<code>\\n\"+\n",
" \"from bokeh.resources import INLINE\\n\"+\n",
" \"output_notebook(resources=INLINE)\\n\"+\n",
" \"</code>\\n\"+\n",
" \"</div>\"}};\n",
"\n",
" function display_loaded() {\n",
" var el = document.getElementById(null);\n",
" if (el != null) {\n",
" el.textContent = \"BokehJS is loading...\";\n",
" }\n",
" if (root.Bokeh !== undefined) {\n",
" if (el != null) {\n",
" el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n",
" }\n",
" } else if (Date.now() < root._bokeh_timeout) {\n",
" setTimeout(display_loaded, 100)\n",
" }\n",
" }\n",
"\n",
"\n",
" function run_callbacks() {\n",
" try {\n",
" root._bokeh_onload_callbacks.forEach(function(callback) {\n",
" if (callback != null)\n",
" callback();\n",
" });\n",
" } finally {\n",
" delete root._bokeh_onload_callbacks\n",
" }\n",
" console.debug(\"Bokeh: all callbacks have finished\");\n",
" }\n",
"\n",
" function load_libs(css_urls, js_urls, callback) {\n",
" if (css_urls == null) css_urls = [];\n",
" if (js_urls == null) js_urls = [];\n",
"\n",
" root._bokeh_onload_callbacks.push(callback);\n",
" if (root._bokeh_is_loading > 0) {\n",
" console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n",
" return null;\n",
" }\n",
" if (js_urls == null || js_urls.length === 0) {\n",
" run_callbacks();\n",
" return null;\n",
" }\n",
" console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n",
" root._bokeh_is_loading = css_urls.length + js_urls.length;\n",
"\n",
" function on_load() {\n",
" root._bokeh_is_loading--;\n",
" if (root._bokeh_is_loading === 0) {\n",
" console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n",
" run_callbacks()\n",
" }\n",
" }\n",
"\n",
" function on_error() {\n",
" console.error(\"failed to load \" + url);\n",
" }\n",
"\n",
" for (var i = 0; i < css_urls.length; i++) {\n",
" var url = css_urls[i];\n",
" const element = document.createElement(\"link\");\n",
" element.onload = on_load;\n",
" element.onerror = on_error;\n",
" element.rel = \"stylesheet\";\n",
" element.type = \"text/css\";\n",
" element.href = url;\n",
" console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n",
" document.body.appendChild(element);\n",
" }\n",
"\n",
" const hashes = {\"https://cdn.bokeh.org/bokeh/release/bokeh-2.1.1.min.js\": \"kLr4fYcqcSpbuI95brIH3vnnYCquzzSxHPU6XGQCIkQRGJwhg0StNbj1eegrHs12\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.1.1.min.js\": \"xIGPmVtaOm+z0BqfSOMn4lOR6ciex448GIKG4eE61LsAvmGj48XcMQZtKcE/UXZe\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.1.1.min.js\": \"Dc9u1wF/0zApGIWoBbH77iWEHtdmkuYWG839Uzmv8y8yBLXebjO9ZnERsde5Ln/P\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.1.1.min.js\": \"cT9JaBz7GiRXdENrJLZNSC6eMNF3nh3fa5fTF51Svp+ukxPdwcU5kGXGPBgDCa2j\"};\n",
"\n",
" for (var i = 0; i < js_urls.length; i++) {\n",
" var url = js_urls[i];\n",
" var element = document.createElement('script');\n",
" element.onload = on_load;\n",
" element.onerror = on_error;\n",
" element.async = false;\n",
" element.src = url;\n",
" if (url in hashes) {\n",
" element.crossOrigin = \"anonymous\";\n",
" element.integrity = \"sha384-\" + hashes[url];\n",
" }\n",
" console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n",
" document.head.appendChild(element);\n",
" }\n",
" };\n",
"\n",
" function inject_raw_css(css) {\n",
" const element = document.createElement(\"style\");\n",
" element.appendChild(document.createTextNode(css));\n",
" document.body.appendChild(element);\n",
" }\n",
"\n",
" \n",
" var js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.1.1.min.js\"];\n",
" var css_urls = [];\n",
" \n",
"\n",
" var inline_js = [\n",
" function(Bokeh) {\n",
" Bokeh.set_log_level(\"info\");\n",
" },\n",
" function(Bokeh) {\n",
" \n",
" \n",
" }\n",
" ];\n",
"\n",
" function run_inline_js() {\n",
" \n",
" if (root.Bokeh !== undefined || force === true) {\n",
" \n",
" for (var i = 0; i < inline_js.length; i++) {\n",
" inline_js[i].call(root, root.Bokeh);\n",
" }\n",
" } else if (Date.now() < root._bokeh_timeout) {\n",
" setTimeout(run_inline_js, 100);\n",
" } else if (!root._bokeh_failed_load) {\n",
" console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n",
" root._bokeh_failed_load = true;\n",
" } else if (force !== true) {\n",
" var cell = $(document.getElementById(null)).parents('.cell').data().cell;\n",
" cell.output_area.append_execute_result(NB_LOAD_WARNING)\n",
" }\n",
"\n",
" }\n",
"\n",
" if (root._bokeh_is_loading === 0) {\n",
" console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n",
" run_inline_js();\n",
" } else {\n",
" load_libs(css_urls, js_urls, function() {\n",
" console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n",
" run_inline_js();\n",
" });\n",
" }\n",
"}(window));"
],
"application/vnd.bokehjs_load.v0+json": "\n(function(root) {\n function now() {\n return new Date();\n }\n\n var force = true;\n\n if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\n \n\n \n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n var NB_LOAD_WARNING = {'data': {'text/html':\n \"<div style='background-color: #fdd'>\\n\"+\n \"<p>\\n\"+\n \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n \"</p>\\n\"+\n \"<ul>\\n\"+\n \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n \"<li>use INLINE resources instead, as so:</li>\\n\"+\n \"</ul>\\n\"+\n \"<code>\\n\"+\n \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"</code>\\n\"+\n \"</div>\"}};\n\n function display_loaded() {\n var el = document.getElementById(null);\n if (el != null) {\n el.textContent = \"BokehJS is loading...\";\n }\n if (root.Bokeh !== undefined) {\n if (el != null) {\n el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(display_loaded, 100)\n }\n }\n\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) {\n if (callback != null)\n callback();\n });\n } finally {\n delete root._bokeh_onload_callbacks\n }\n console.debug(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(css_urls, js_urls, callback) {\n if (css_urls == null) css_urls = [];\n if (js_urls == null) js_urls = [];\n\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls == null || js_urls.length === 0) {\n run_callbacks();\n return null;\n }\n console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n root._bokeh_is_loading = css_urls.length + js_urls.length;\n\n function on_load() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n run_callbacks()\n }\n }\n\n function on_error() {\n console.error(\"failed to load \" + url);\n }\n\n for (var i = 0; i < css_urls.length; i++) {\n var url = css_urls[i];\n const element = document.createElement(\"link\");\n element.onload = on_load;\n element.onerror = on_error;\n element.rel = \"stylesheet\";\n element.type = \"text/css\";\n element.href = url;\n console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n document.body.appendChild(element);\n }\n\n const hashes = {\"https://cdn.bokeh.org/bokeh/release/bokeh-2.1.1.min.js\": \"kLr4fYcqcSpbuI95brIH3vnnYCquzzSxHPU6XGQCIkQRGJwhg0StNbj1eegrHs12\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.1.1.min.js\": \"xIGPmVtaOm+z0BqfSOMn4lOR6ciex448GIKG4eE61LsAvmGj48XcMQZtKcE/UXZe\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.1.1.min.js\": \"Dc9u1wF/0zApGIWoBbH77iWEHtdmkuYWG839Uzmv8y8yBLXebjO9ZnERsde5Ln/P\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.1.1.min.js\": \"cT9JaBz7GiRXdENrJLZNSC6eMNF3nh3fa5fTF51Svp+ukxPdwcU5kGXGPBgDCa2j\"};\n\n for (var i = 0; i < js_urls.length; i++) {\n var url = js_urls[i];\n var element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error;\n element.async = false;\n element.src = url;\n if (url in hashes) {\n element.crossOrigin = \"anonymous\";\n element.integrity = \"sha384-\" + hashes[url];\n }\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n };\n\n function inject_raw_css(css) {\n const element = document.createElement(\"style\");\n element.appendChild(document.createTextNode(css));\n document.body.appendChild(element);\n }\n\n \n var js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.1.1.min.js\"];\n var css_urls = [];\n \n\n var inline_js = [\n function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\n function(Bokeh) {\n \n \n }\n ];\n\n function run_inline_js() {\n \n if (root.Bokeh !== undefined || force === true) {\n \n for (var i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n } else if (force !== true) {\n var cell = $(document.getElementById(null)).parents('.cell').data().cell;\n cell.output_area.append_execute_result(NB_LOAD_WARNING)\n }\n\n }\n\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(css_urls, js_urls, function() {\n console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));"
},
"metadata": {
"tags": []
}
},
{
"output_type": "display_data",
"data": {
"text/html": [
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
" <div class=\"bk-root\" id=\"c5cc4e47-56ad-4242-912a-4973ed1dc711\" data-root-id=\"1949\"></div>\n"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "display_data",
"data": {
"application/javascript": [
"(function(root) {\n",
" function embed_document(root) {\n",
" \n",
" var docs_json = {\"bdc023f8-8e58-4752-a2ea-df6ec7d35e21\":{\"roots\":{\"references\":[{\"attributes\":{\"below\":[{\"id\":\"1958\"}],\"center\":[{\"id\":\"1960\"},{\"id\":\"1964\"},{\"id\":\"1993\"}],\"left\":[{\"id\":\"1961\"}],\"plot_height\":400,\"renderers\":[{\"id\":\"1982\"},{\"id\":\"2000\"},{\"id\":\"2017\"},{\"id\":\"2034\"},{\"id\":\"2051\"}],\"title\":{\"id\":\"1985\"},\"toolbar\":{\"id\":\"1972\"},\"x_range\":{\"id\":\"1950\"},\"x_scale\":{\"id\":\"1954\"},\"y_range\":{\"id\":\"1952\"},\"y_scale\":{\"id\":\"1956\"}},\"id\":\"1949\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_multi\":null,\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"1965\"},{\"id\":\"1966\"},{\"id\":\"1967\"},{\"id\":\"1968\"},{\"id\":\"1969\"},{\"id\":\"1970\"},{\"id\":\"1995\"},{\"id\":\"2012\"},{\"id\":\"2029\"},{\"id\":\"2046\"},{\"id\":\"2063\"}]},\"id\":\"1972\",\"type\":\"Toolbar\"},{\"attributes\":{\"axis\":{\"id\":\"1961\"},\"dimension\":1,\"ticker\":null},\"id\":\"1964\",\"type\":\"Grid\"},{\"attributes\":{\"line_alpha\":0.1,\"line_color\":\"#e6ab02\",\"x\":{\"field\":\"exp\"},\"y\":{\"field\":\"bootcamp\"}},\"id\":\"2050\",\"type\":\"Line\"},{\"attributes\":{\"text\":\"Evoluci\\u00f3n de donde aprendemos a programar\"},\"id\":\"1985\",\"type\":\"Title\"},{\"attributes\":{\"line_color\":\"#e7298a\",\"x\":{\"field\":\"exp\"},\"y\":{\"field\":\"trabajo\"}},\"id\":\"2015\",\"type\":\"Line\"},{\"attributes\":{\"callback\":null,\"renderers\":[{\"id\":\"2051\"}],\"tooltips\":[[\"Formaci\\u00f3n\",\"bootcamp\"],[\"Pct\",\"@bootcamp{0%}\"]]},\"id\":\"2063\",\"type\":\"HoverTool\"},{\"attributes\":{},\"id\":\"1956\",\"type\":\"LinearScale\"},{\"attributes\":{\"label\":{\"value\":\"online\"},\"renderers\":[{\"id\":\"2034\"}]},\"id\":\"2045\",\"type\":\"LegendItem\"},{\"attributes\":{\"axis\":{\"id\":\"1958\"},\"ticker\":null},\"id\":\"1960\",\"type\":\"Grid\"},{\"attributes\":{\"line_alpha\":0.1,\"line_color\":\"#66a61e\",\"x\":{\"field\":\"exp\"},\"y\":{\"field\":\"online\"}},\"id\":\"2033\",\"type\":\"Line\"},{\"attributes\":{\"line_alpha\":0.1,\"line_color\":\"#7570b3\",\"x\":{\"field\":\"exp\"},\"y\":{\"field\":\"autodidacta\"}},\"id\":\"1999\",\"type\":\"Line\"},{\"attributes\":{\"data_source\":{\"id\":\"1948\"},\"glyph\":{\"id\":\"2032\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"2033\"},\"selection_glyph\":null,\"view\":{\"id\":\"2035\"}},\"id\":\"2034\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"axis_label\":\"Experiencia (a\\u00f1os)\",\"formatter\":{\"id\":\"1988\"},\"ticker\":{\"id\":\"1959\"}},\"id\":\"1958\",\"type\":\"CategoricalAxis\"},{\"attributes\":{\"factors\":[\"20+\",\"15-20\",\"11-14\",\"9-10\",\"7-8\",\"5-6\",\"3-4\",\"0-2\"]},\"id\":\"1950\",\"type\":\"FactorRange\"},{\"attributes\":{\"source\":{\"id\":\"1948\"}},\"id\":\"2018\",\"type\":\"CDSView\"},{\"attributes\":{\"data_source\":{\"id\":\"1948\"},\"glyph\":{\"id\":\"2049\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"2050\"},\"selection_glyph\":null,\"view\":{\"id\":\"2052\"}},\"id\":\"2051\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"format\":\"0%\"},\"id\":\"2066\",\"type\":\"NumeralTickFormatter\"},{\"attributes\":{},\"id\":\"1988\",\"type\":\"CategoricalTickFormatter\"},{\"attributes\":{\"line_alpha\":0.1,\"line_color\":\"#e7298a\",\"x\":{\"field\":\"exp\"},\"y\":{\"field\":\"trabajo\"}},\"id\":\"2016\",\"type\":\"Line\"},{\"attributes\":{\"line_color\":\"#e6ab02\",\"x\":{\"field\":\"exp\"},\"y\":{\"field\":\"bootcamp\"}},\"id\":\"2049\",\"type\":\"Line\"},{\"attributes\":{\"label\":{\"value\":\"autodidacta\"},\"renderers\":[{\"id\":\"2000\"}]},\"id\":\"2011\",\"type\":\"LegendItem\"},{\"attributes\":{\"line_color\":\"#66a61e\",\"x\":{\"field\":\"exp\"},\"y\":{\"field\":\"online\"}},\"id\":\"2032\",\"type\":\"Line\"},{\"attributes\":{\"source\":{\"id\":\"1948\"}},\"id\":\"2035\",\"type\":\"CDSView\"},{\"attributes\":{\"data_source\":{\"id\":\"1948\"},\"glyph\":{\"id\":\"2015\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"2016\"},\"selection_glyph\":null,\"view\":{\"id\":\"2018\"}},\"id\":\"2017\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"line_color\":\"#d95f02\",\"x\":{\"field\":\"exp\"},\"y\":{\"field\":\"escuela\"}},\"id\":\"1980\",\"type\":\"Line\"},{\"attributes\":{},\"id\":\"1966\",\"type\":\"WheelZoomTool\"},{\"attributes\":{\"callback\":null,\"renderers\":[{\"id\":\"2000\"}],\"tooltips\":[[\"Formaci\\u00f3n\",\"autodidacta\"],[\"Pct\",\"@autodidacta{0%}\"]]},\"id\":\"2012\",\"type\":\"HoverTool\"},{\"attributes\":{\"callback\":null,\"renderers\":[{\"id\":\"2034\"}],\"tooltips\":[[\"Formaci\\u00f3n\",\"online\"],[\"Pct\",\"@online{0%}\"]]},\"id\":\"2046\",\"type\":\"HoverTool\"},{\"attributes\":{\"data_source\":{\"id\":\"1948\"},\"glyph\":{\"id\":\"1998\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"1999\"},\"selection_glyph\":null,\"view\":{\"id\":\"2001\"}},\"id\":\"2000\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"1968\",\"type\":\"SaveTool\"},{\"attributes\":{\"callback\":null,\"renderers\":[{\"id\":\"1982\"}],\"tooltips\":[[\"Formaci\\u00f3n\",\"escuela\"],[\"Pct\",\"@escuela{0%}\"]]},\"id\":\"1995\",\"type\":\"HoverTool\"},{\"attributes\":{\"label\":{\"value\":\"trabajo\"},\"renderers\":[{\"id\":\"2017\"}]},\"id\":\"2028\",\"type\":\"LegendItem\"},{\"attributes\":{},\"id\":\"1952\",\"type\":\"DataRange1d\"},{\"attributes\":{\"label\":{\"value\":\"bootcamp\"},\"renderers\":[{\"id\":\"2051\"}]},\"id\":\"2062\",\"type\":\"LegendItem\"},{\"attributes\":{\"axis_label\":\"Porcentaje\",\"formatter\":{\"id\":\"2066\"},\"ticker\":{\"id\":\"1962\"}},\"id\":\"1961\",\"type\":\"LinearAxis\"},{\"attributes\":{\"callback\":null,\"renderers\":[{\"id\":\"2017\"}],\"tooltips\":[[\"Formaci\\u00f3n\",\"trabajo\"],[\"Pct\",\"@trabajo{0%}\"]]},\"id\":\"2029\",\"type\":\"HoverTool\"},{\"attributes\":{},\"id\":\"1954\",\"type\":\"CategoricalScale\"},{\"attributes\":{},\"id\":\"1969\",\"type\":\"ResetTool\"},{\"attributes\":{\"source\":{\"id\":\"1948\"}},\"id\":\"2001\",\"type\":\"CDSView\"},{\"attributes\":{\"label\":{\"value\":\"escuela\"},\"renderers\":[{\"id\":\"1982\"}]},\"id\":\"1994\",\"type\":\"LegendItem\"},{\"attributes\":{},\"id\":\"1965\",\"type\":\"PanTool\"},{\"attributes\":{\"source\":{\"id\":\"1948\"}},\"id\":\"1983\",\"type\":\"CDSView\"},{\"attributes\":{\"data\":{\"autodidacta\":{\"__ndarray__\":\"KMRZ+Qlxxj9ruPghDHLGP2xwscHFBsc/5RdLfrHkxz+VNWVNWVPGPyJwYxmUCsM/ip3YiZ3YwT98bolTv+e2Pw==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[8]},\"bootcamp\":{\"__ndarray__\":\"vmNqYO+Yej9IB97zjWmDP3CxwcUGF5s/exSuR+F6lD/0BX1BX9B3P5Cc5mv17JA/sRM7sRM7sT/tWIEw0o61Pw==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[8]},\"escuela\":{\"__ndarray__\":\"75ga2Dum5j+Qs2R/rSvkP7Msy7Isy+I/H4XrUbge5T/ijrgj7ojjP3k/cpqv1eM/O7ETO7ET4z/7PbfEqd/jPw==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[8]},\"exp\":[\"20+\",\"15-20\",\"11-14\",\"9-10\",\"7-8\",\"5-6\",\"3-4\",\"0-2\"],\"index\":[7,6,5,4,3,2,1,0],\"online\":{\"__ndarray__\":\"vmNqYO+Yij/rCs3tVB6dP2gvob2E9qI/TxvotIFOmz93xB1xR9yxP6FUmHg/cro/J3ZiJ3Zitz/V77klTv2+Pw==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[8]},\"trabajo\":{\"__ndarray__\":\"gr1jamDvuD+C93xj2gTEP8BaAWsFrMU/TxvotIFOuz93xB1xR9zBPzMoFSbej7w/O7ETO7ETuz/tWIEw0o61Pw==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[8]}},\"selected\":{\"id\":\"1991\"},\"selection_policy\":{\"id\":\"1992\"}},\"id\":\"1948\",\"type\":\"ColumnDataSource\"},{\"attributes\":{},\"id\":\"1992\",\"type\":\"UnionRenderers\"},{\"attributes\":{},\"id\":\"1991\",\"type\":\"Selection\"},{\"attributes\":{\"line_alpha\":0.1,\"line_color\":\"#d95f02\",\"x\":{\"field\":\"exp\"},\"y\":{\"field\":\"escuela\"}},\"id\":\"1981\",\"type\":\"Line\"},{\"attributes\":{\"source\":{\"id\":\"1948\"}},\"id\":\"2052\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"1970\",\"type\":\"HelpTool\"},{\"attributes\":{},\"id\":\"1962\",\"type\":\"BasicTicker\"},{\"attributes\":{\"data_source\":{\"id\":\"1948\"},\"glyph\":{\"id\":\"1980\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"1981\"},\"selection_glyph\":null,\"view\":{\"id\":\"1983\"}},\"id\":\"1982\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"items\":[{\"id\":\"1994\"},{\"id\":\"2011\"},{\"id\":\"2028\"},{\"id\":\"2045\"},{\"id\":\"2062\"}],\"location\":[400,120]},\"id\":\"1993\",\"type\":\"Legend\"},{\"attributes\":{\"line_color\":\"#7570b3\",\"x\":{\"field\":\"exp\"},\"y\":{\"field\":\"autodidacta\"}},\"id\":\"1998\",\"type\":\"Line\"},{\"attributes\":{},\"id\":\"1959\",\"type\":\"CategoricalTicker\"},{\"attributes\":{\"overlay\":{\"id\":\"1971\"}},\"id\":\"1967\",\"type\":\"BoxZoomTool\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":0.5,\"fill_color\":\"lightgrey\",\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":1.0,\"line_color\":\"black\",\"line_dash\":[4,4],\"line_width\":2,\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"1971\",\"type\":\"BoxAnnotation\"}],\"root_ids\":[\"1949\"]},\"title\":\"Bokeh Application\",\"version\":\"2.1.1\"}};\n",
" var render_items = [{\"docid\":\"bdc023f8-8e58-4752-a2ea-df6ec7d35e21\",\"root_ids\":[\"1949\"],\"roots\":{\"1949\":\"c5cc4e47-56ad-4242-912a-4973ed1dc711\"}}];\n",
" root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n",
"\n",
" }\n",
" if (root.Bokeh !== undefined) {\n",
" embed_document(root);\n",
" } else {\n",
" var attempts = 0;\n",
" var timer = setInterval(function(root) {\n",
" if (root.Bokeh !== undefined) {\n",
" clearInterval(timer);\n",
" embed_document(root);\n",
" } else {\n",
" attempts++;\n",
" if (attempts > 100) {\n",
" clearInterval(timer);\n",
" console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n",
" }\n",
" }\n",
" }, 10, root)\n",
" }\n",
"})(window);"
],
"application/vnd.bokehjs_exec.v0+json": ""
},
"metadata": {
"tags": [],
"application/vnd.bokehjs_exec.v0+json": {
"id": "1949"
}
}
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "5txM34Jt1pY7"
},
"source": [
"Llama la atención el crecimiento de los cursos online."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "1jhZFS4c1pY7"
},
"source": [
"## Cliente local vs internacional"
]
},
{
"cell_type": "code",
"metadata": {
"id": "-_ZXSbRB1pY7",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 136
},
"outputId": "6f9c33cc-40ec-463e-9044-157a4356bf83"
},
"source": [
"table = df.groupby(\"remote\")[\"salarymx\"].agg(['count', 'median', 'mean', 'std']).sort_values(by=['median'], ascending=False)\n",
"table.head(20)"
],
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>count</th>\n",
" <th>median</th>\n",
" <th>mean</th>\n",
" <th>std</th>\n",
" </tr>\n",
" <tr>\n",
" <th>remote</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>Y</th>\n",
" <td>616</td>\n",
" <td>54000</td>\n",
" <td>60368.896104</td>\n",
" <td>37177.568724</td>\n",
" </tr>\n",
" <tr>\n",
" <th>N</th>\n",
" <td>900</td>\n",
" <td>33000</td>\n",
" <td>38488.628889</td>\n",
" <td>29384.442119</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" count median mean std\n",
"remote \n",
"Y 616 54000 60368.896104 37177.568724\n",
"N 900 33000 38488.628889 29384.442119"
]
},
"metadata": {
"tags": []
},
"execution_count": 57
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "nLkkyhDK1pY8",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 284
},
"outputId": "dbb68724-bad9-435e-dd03-a21b88e2b8d1"
},
"source": [
"table = df.groupby(\"orgtype\")[\"salarymx\"].agg(['count', 'median', 'mean', 'std']).sort_values(by=['median'], ascending=False)\n",
"table.head(20)"
],
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>count</th>\n",
" <th>median</th>\n",
" <th>mean</th>\n",
" <th>std</th>\n",
" </tr>\n",
" <tr>\n",
" <th>orgtype</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>startup</th>\n",
" <td>201</td>\n",
" <td>55000</td>\n",
" <td>64923.656716</td>\n",
" <td>48645.533738</td>\n",
" </tr>\n",
" <tr>\n",
" <th>itservices</th>\n",
" <td>706</td>\n",
" <td>44000</td>\n",
" <td>47950.423513</td>\n",
" <td>27986.088832</td>\n",
" </tr>\n",
" <tr>\n",
" <th>isv</th>\n",
" <td>170</td>\n",
" <td>40750</td>\n",
" <td>50546.935294</td>\n",
" <td>40105.597955</td>\n",
" </tr>\n",
" <tr>\n",
" <th>corp</th>\n",
" <td>286</td>\n",
" <td>35000</td>\n",
" <td>38598.475524</td>\n",
" <td>24639.388552</td>\n",
" </tr>\n",
" <tr>\n",
" <th>freelance</th>\n",
" <td>35</td>\n",
" <td>34000</td>\n",
" <td>59811.685714</td>\n",
" <td>63703.017036</td>\n",
" </tr>\n",
" <tr>\n",
" <th>gobierno</th>\n",
" <td>53</td>\n",
" <td>25000</td>\n",
" <td>30732.735849</td>\n",
" <td>26085.815307</td>\n",
" </tr>\n",
" <tr>\n",
" <th>uni</th>\n",
" <td>65</td>\n",
" <td>20000</td>\n",
" <td>24153.307692</td>\n",
" <td>16140.492322</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" count median mean std\n",
"orgtype \n",
"startup 201 55000 64923.656716 48645.533738\n",
"itservices 706 44000 47950.423513 27986.088832\n",
"isv 170 40750 50546.935294 40105.597955\n",
"corp 286 35000 38598.475524 24639.388552\n",
"freelance 35 34000 59811.685714 63703.017036\n",
"gobierno 53 25000 30732.735849 26085.815307\n",
"uni 65 20000 24153.307692 16140.492322"
]
},
"metadata": {
"tags": []
},
"execution_count": 58
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "vGPznNgu1pY8"
},
"source": [
"## Covid-19"
]
},
{
"cell_type": "code",
"metadata": {
"id": "Pl0Ua2fR1pY8",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "2929f647-a726-44bc-fcdc-744197f50056"
},
"source": [
"covid = df[[\"covid_carga\",\"covid_remoto\", \"covid_salario\", \"covid_apoyo\"]].copy()\n",
"covid.value_counts([\"covid_remoto\"])\n",
"\n",
"\n"
],
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"covid_remoto\n",
"remote 1399\n",
"onsite 116\n",
"dtype: int64"
]
},
"metadata": {
"tags": []
},
"execution_count": 59
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dknGkRcu1pY8"
},
"source": [
"## Special cases"
]
},
{
"cell_type": "code",
"metadata": {
"id": "OZNCf64O1pY8",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 225
},
"outputId": "fb5619ba-b226-4c16-925b-73f4180116e9"
},
"source": [
"segment = df[(df[\"city\"] == \"Guadalajara\") & (df[\"experience\"]>6)]\n",
"ingles = segment.groupby(\"english_label\")[\"salarymx\"].agg(['count', 'median', 'mean', 'std']).sort_values(by=['median'], ascending=False)\n",
"ingles.head(20)\n"
],
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>count</th>\n",
" <th>median</th>\n",
" <th>mean</th>\n",
" <th>std</th>\n",
" </tr>\n",
" <tr>\n",
" <th>english_label</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>Nativo o bilingue (ILR 5)</th>\n",
" <td>6</td>\n",
" <td>125000</td>\n",
" <td>102666.666667</td>\n",
" <td>44862.753668</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Avanzado: Puedo conversar y escribir sin problemas sobre cualquier tema (ILR 4)</th>\n",
" <td>49</td>\n",
" <td>79000</td>\n",
" <td>80554.448980</td>\n",
" <td>33499.809251</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Profesional: Puedo interactuar profesionalmente con colegas y clientes (ILR 3)</th>\n",
" <td>47</td>\n",
" <td>60000</td>\n",
" <td>62978.765957</td>\n",
" <td>17708.077506</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Limitado: Me doy a entender pero con errores de gramática (ILR 2)</th>\n",
" <td>12</td>\n",
" <td>47500</td>\n",
" <td>51000.000000</td>\n",
" <td>26700.357505</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Elemental: Sé lo básico para sobrevivir (ILR 1)</th>\n",
" <td>2</td>\n",
" <td>16500</td>\n",
" <td>16500.000000</td>\n",
" <td>23334.523779</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" count ... std\n",
"english_label ... \n",
"Nativo o bilingue (ILR 5) 6 ... 44862.753668\n",
"Avanzado: Puedo conversar y escribir sin proble... 49 ... 33499.809251\n",
"Profesional: Puedo interactuar profesionalmente... 47 ... 17708.077506\n",
"Limitado: Me doy a entender pero con errores de... 12 ... 26700.357505\n",
"Elemental: Sé lo básico para sobrevivir (ILR 1) 2 ... 23334.523779\n",
"\n",
"[5 rows x 4 columns]"
]
},
"metadata": {
"tags": []
},
"execution_count": 60
}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment