{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Bienvenides\n", "\n", "En esta notebook vamos a levantar un archivo con las respuestas de algun cuatrimestre del cursito de python de la FIFA con Pandas, y vamos también a trabajarlo un poco para ver qué tipo de cosas se pueden hacer y qué información sacar de los datos" ] }, { "cell_type": "code", "execution_count": 171, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Timestamp¿Que día/horarios te conviene? [Lunes]¿Que día/horarios te conviene? [Martes]¿Que día/horarios te conviene? [Miercoles]¿Que día/horarios te conviene? [Jueves]¿Que día/horarios te conviene? [Viernes]¿Cuantos sabes de programación?¿Tenes algún tema o librería en particular que te gustaría aprender?(esta pregunta es opcional)
029/03/2020 18:04:09Mañana(1030-1330)Mañana(1030-1330)Mañana(1030-1330)Mañana(1030-1330)Mañana(1030-1330)3NaN
129/03/2020 18:09:10Tarde(1330-1630)Tarde(1330-1630)Tarde(1330-1630)Tarde(1330-1630)Tarde(1330-1630)1NaN
229/03/2020 18:21:25Mañana(1030-1330)Mañana(1030-1330)Mañana(1030-1330)Mañana(1030-1330)Mañana(1030-1330)1NaN
329/03/2020 18:22:11Mañana(1030-1330), Tarde(1330-1630), Noche(173...Mañana(1030-1330), Tarde(1330-1630), Noche(173...Mañana(1030-1330), Tarde(1330-1630), Noche(173...Mañana(1030-1330), Tarde(1330-1630), Noche(173...Mañana(1030-1330), Tarde(1330-1630), Noche(173...3Programación orientada a objetos
429/03/2020 18:34:15Noche(1730-2030)Noche(1730-2030)Noche(1730-2030)Noche(1730-2030)Noche(1730-2030)1NaN
...........................
16604/04/2020 07:55:21Mañana(1030-1330)Mañana(1030-1330)Mañana(1030-1330)Mañana(1030-1330)Mañana(1030-1330)1NaN
16704/04/2020 09:55:16NingunaTarde(1330-1630)Tarde(1330-1630)Tarde(1330-1630)Ninguna1NaN
16804/04/2020 13:35:21Mañana(1030-1330)Mañana(1030-1330)Mañana(1030-1330)Mañana(1030-1330)Mañana(1030-1330)2NaN
16904/04/2020 13:40:15Mañana(1030-1330)Mañana(1030-1330), Tarde(1330-1630)Mañana(1030-1330)Mañana(1030-1330), Tarde(1330-1630)Mañana(1030-1330)1NaN
17004/04/2020 14:20:55Mañana(1030-1330)Mañana(1030-1330), Tarde(1330-1630), Noche(173...Mañana(1030-1330), Tarde(1330-1630)Mañana(1030-1330), Tarde(1330-1630), Noche(173...Mañana(1030-1330)1NaN
\n", "

171 rows × 8 columns

\n", "
" ], "text/plain": [ " Timestamp ¿Que día/horarios te conviene? [Lunes] \\\n", "0 29/03/2020 18:04:09 Mañana(1030-1330) \n", "1 29/03/2020 18:09:10 Tarde(1330-1630) \n", "2 29/03/2020 18:21:25 Mañana(1030-1330) \n", "3 29/03/2020 18:22:11 Mañana(1030-1330), Tarde(1330-1630), Noche(173... \n", "4 29/03/2020 18:34:15 Noche(1730-2030) \n", ".. ... ... \n", "166 04/04/2020 07:55:21 Mañana(1030-1330) \n", "167 04/04/2020 09:55:16 Ninguna \n", "168 04/04/2020 13:35:21 Mañana(1030-1330) \n", "169 04/04/2020 13:40:15 Mañana(1030-1330) \n", "170 04/04/2020 14:20:55 Mañana(1030-1330) \n", "\n", " ¿Que día/horarios te conviene? [Martes] \\\n", "0 Mañana(1030-1330) \n", "1 Tarde(1330-1630) \n", "2 Mañana(1030-1330) \n", "3 Mañana(1030-1330), Tarde(1330-1630), Noche(173... \n", "4 Noche(1730-2030) \n", ".. ... \n", "166 Mañana(1030-1330) \n", "167 Tarde(1330-1630) \n", "168 Mañana(1030-1330) \n", "169 Mañana(1030-1330), Tarde(1330-1630) \n", "170 Mañana(1030-1330), Tarde(1330-1630), Noche(173... \n", "\n", " ¿Que día/horarios te conviene? [Miercoles] \\\n", "0 Mañana(1030-1330) \n", "1 Tarde(1330-1630) \n", "2 Mañana(1030-1330) \n", "3 Mañana(1030-1330), Tarde(1330-1630), Noche(173... \n", "4 Noche(1730-2030) \n", ".. ... \n", "166 Mañana(1030-1330) \n", "167 Tarde(1330-1630) \n", "168 Mañana(1030-1330) \n", "169 Mañana(1030-1330) \n", "170 Mañana(1030-1330), Tarde(1330-1630) \n", "\n", " ¿Que día/horarios te conviene? [Jueves] \\\n", "0 Mañana(1030-1330) \n", "1 Tarde(1330-1630) \n", "2 Mañana(1030-1330) \n", "3 Mañana(1030-1330), Tarde(1330-1630), Noche(173... \n", "4 Noche(1730-2030) \n", ".. ... \n", "166 Mañana(1030-1330) \n", "167 Tarde(1330-1630) \n", "168 Mañana(1030-1330) \n", "169 Mañana(1030-1330), Tarde(1330-1630) \n", "170 Mañana(1030-1330), Tarde(1330-1630), Noche(173... \n", "\n", " ¿Que día/horarios te conviene? [Viernes] \\\n", "0 Mañana(1030-1330) \n", "1 Tarde(1330-1630) \n", "2 Mañana(1030-1330) \n", "3 Mañana(1030-1330), Tarde(1330-1630), Noche(173... \n", "4 Noche(1730-2030) \n", ".. ... \n", "166 Mañana(1030-1330) \n", "167 Ninguna \n", "168 Mañana(1030-1330) \n", "169 Mañana(1030-1330) \n", "170 Mañana(1030-1330) \n", "\n", " ¿Cuantos sabes de programación? \\\n", "0 3 \n", "1 1 \n", "2 1 \n", "3 3 \n", "4 1 \n", ".. ... \n", "166 1 \n", "167 1 \n", "168 2 \n", "169 1 \n", "170 1 \n", "\n", " ¿Tenes algún tema o librería en particular que te gustaría aprender?(esta pregunta es opcional) \n", "0 NaN \n", "1 NaN \n", "2 NaN \n", "3 Programación orientada a objetos \n", "4 NaN \n", ".. ... \n", "166 NaN \n", "167 NaN \n", "168 NaN \n", "169 NaN \n", "170 NaN \n", "\n", "[171 rows x 8 columns]" ] }, "execution_count": 171, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import pandas as pd\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "import datetime\n", "\n", "%matplotlib notebook\n", "respuestas = pd.read_csv(\"respuestas.csv\")\n", "respuestas" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Es un poco molesto de ver asi la tabla, porque cada horario tiene mucha información que estaba en el form, pero ya no nos sirve, entones podemos reemplazar cada turno por algo mas corto, así como tambien cambiar las preguntas que también son muy largas." ] }, { "cell_type": "code", "execution_count": 172, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
TiempoLunMarMieJueVieNivelExtras
029/03/2020 18:04:09ManManManManMan3NaN
129/03/2020 18:09:10TarTarTarTarTar1NaN
229/03/2020 18:21:25ManManManManMan1NaN
329/03/2020 18:22:11Man, Tar, NocMan, Tar, NocMan, Tar, NocMan, Tar, NocMan, Tar, Noc3Programación orientada a objetos
429/03/2020 18:34:15NocNocNocNocNoc1NaN
...........................
16604/04/2020 07:55:21ManManManManMan1NaN
16704/04/2020 09:55:16NoneTarTarTarNone1NaN
16804/04/2020 13:35:21ManManManManMan2NaN
16904/04/2020 13:40:15ManMan, TarManMan, TarMan1NaN
17004/04/2020 14:20:55ManMan, Tar, NocMan, TarMan, Tar, NocMan1NaN
\n", "

171 rows × 8 columns

\n", "
" ], "text/plain": [ " Tiempo Lun Mar Mie \\\n", "0 29/03/2020 18:04:09 Man Man Man \n", "1 29/03/2020 18:09:10 Tar Tar Tar \n", "2 29/03/2020 18:21:25 Man Man Man \n", "3 29/03/2020 18:22:11 Man, Tar, Noc Man, Tar, Noc Man, Tar, Noc \n", "4 29/03/2020 18:34:15 Noc Noc Noc \n", ".. ... ... ... ... \n", "166 04/04/2020 07:55:21 Man Man Man \n", "167 04/04/2020 09:55:16 None Tar Tar \n", "168 04/04/2020 13:35:21 Man Man Man \n", "169 04/04/2020 13:40:15 Man Man, Tar Man \n", "170 04/04/2020 14:20:55 Man Man, Tar, Noc Man, Tar \n", "\n", " Jue Vie Nivel Extras \n", "0 Man Man 3 NaN \n", "1 Tar Tar 1 NaN \n", "2 Man Man 1 NaN \n", "3 Man, Tar, Noc Man, Tar, Noc 3 Programación orientada a objetos \n", "4 Noc Noc 1 NaN \n", ".. ... ... ... ... \n", "166 Man Man 1 NaN \n", "167 Tar None 1 NaN \n", "168 Man Man 2 NaN \n", "169 Man, Tar Man 1 NaN \n", "170 Man, Tar, Noc Man 1 NaN \n", "\n", "[171 rows x 8 columns]" ] }, "execution_count": 172, "metadata": {}, "output_type": "execute_result" } ], "source": [ "respuestas.columns = ['Tiempo', 'Lun', 'Mar', 'Mie', 'Jue', 'Vie', 'Nivel', 'Extras']\n", "respuestas.replace({'Mañana\\(1030-1330\\)': 'Man',\n", " 'Tarde\\(1330-1630\\)': 'Tar',\n", " 'Noche\\(1730-2030\\)': 'Noc',\n", " 'Ninguna':\"None\"}, regex=True, inplace=True)\n", "respuestas" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "---\n", "---\n", "Algo trivial de hacer ahora es ver, por ejemplo, la distribución de nivel de la gente que está viniendo al taller. Esto puede servir para enfocar de diferentes maneras los temas que vamos a dar. O bien super básicos, o si podemos apretar más el acelerador y dar mas cosas." ] }, { "cell_type": "code", "execution_count": 176, "metadata": {}, "outputs": [ { "data": { "application/javascript": [ "/* Put everything inside the global mpl namespace */\n", "window.mpl = {};\n", "\n", "\n", "mpl.get_websocket_type = function() {\n", " if (typeof(WebSocket) !== 'undefined') {\n", " return WebSocket;\n", " } else if (typeof(MozWebSocket) !== 'undefined') {\n", " return MozWebSocket;\n", " } else {\n", " alert('Your browser does not have WebSocket support. ' +\n", " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", " 'Firefox 4 and 5 are also supported but you ' +\n", " 'have to enable WebSockets in about:config.');\n", " };\n", "}\n", "\n", "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n", " this.id = figure_id;\n", "\n", " this.ws = websocket;\n", "\n", " this.supports_binary = (this.ws.binaryType != undefined);\n", "\n", " if (!this.supports_binary) {\n", " var warnings = document.getElementById(\"mpl-warnings\");\n", " if (warnings) {\n", " warnings.style.display = 'block';\n", " warnings.textContent = (\n", " \"This browser does not support binary websocket messages. \" +\n", " \"Performance may be slow.\");\n", " }\n", " }\n", "\n", " this.imageObj = new Image();\n", "\n", " this.context = undefined;\n", " this.message = undefined;\n", " this.canvas = undefined;\n", " this.rubberband_canvas = undefined;\n", " this.rubberband_context = undefined;\n", " this.format_dropdown = undefined;\n", "\n", " this.image_mode = 'full';\n", "\n", " this.root = $('
');\n", " this._root_extra_style(this.root)\n", " this.root.attr('style', 'display: inline-block');\n", "\n", " $(parent_element).append(this.root);\n", "\n", " this._init_header(this);\n", " this._init_canvas(this);\n", " this._init_toolbar(this);\n", "\n", " var fig = this;\n", "\n", " this.waiting = false;\n", "\n", " this.ws.onopen = function () {\n", " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", " fig.send_message(\"send_image_mode\", {});\n", " if (mpl.ratio != 1) {\n", " fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n", " }\n", " fig.send_message(\"refresh\", {});\n", " }\n", "\n", " this.imageObj.onload = function() {\n", " if (fig.image_mode == 'full') {\n", " // Full images could contain transparency (where diff images\n", " // almost always do), so we need to clear the canvas so that\n", " // there is no ghosting.\n", " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", " }\n", " fig.context.drawImage(fig.imageObj, 0, 0);\n", " };\n", "\n", " this.imageObj.onunload = function() {\n", " fig.ws.close();\n", " }\n", "\n", " this.ws.onmessage = this._make_on_message_function(this);\n", "\n", " this.ondownload = ondownload;\n", "}\n", "\n", "mpl.figure.prototype._init_header = function() {\n", " var titlebar = $(\n", " '
');\n", " var titletext = $(\n", " '
');\n", " titlebar.append(titletext)\n", " this.root.append(titlebar);\n", " this.header = titletext[0];\n", "}\n", "\n", "\n", "\n", "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n", "\n", "}\n", "\n", "\n", "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n", "\n", "}\n", "\n", "mpl.figure.prototype._init_canvas = function() {\n", " var fig = this;\n", "\n", " var canvas_div = $('
');\n", "\n", " canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n", "\n", " function canvas_keyboard_event(event) {\n", " return fig.key_event(event, event['data']);\n", " }\n", "\n", " canvas_div.keydown('key_press', canvas_keyboard_event);\n", " canvas_div.keyup('key_release', canvas_keyboard_event);\n", " this.canvas_div = canvas_div\n", " this._canvas_extra_style(canvas_div)\n", " this.root.append(canvas_div);\n", "\n", " var canvas = $('');\n", " canvas.addClass('mpl-canvas');\n", " canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n", "\n", " this.canvas = canvas[0];\n", " this.context = canvas[0].getContext(\"2d\");\n", "\n", " var backingStore = this.context.backingStorePixelRatio ||\n", "\tthis.context.webkitBackingStorePixelRatio ||\n", "\tthis.context.mozBackingStorePixelRatio ||\n", "\tthis.context.msBackingStorePixelRatio ||\n", "\tthis.context.oBackingStorePixelRatio ||\n", "\tthis.context.backingStorePixelRatio || 1;\n", "\n", " mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n", "\n", " var rubberband = $('');\n", " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", "\n", " var pass_mouse_events = true;\n", "\n", " canvas_div.resizable({\n", " start: function(event, ui) {\n", " pass_mouse_events = false;\n", " },\n", " resize: function(event, ui) {\n", " fig.request_resize(ui.size.width, ui.size.height);\n", " },\n", " stop: function(event, ui) {\n", " pass_mouse_events = true;\n", " fig.request_resize(ui.size.width, ui.size.height);\n", " },\n", " });\n", "\n", " function mouse_event_fn(event) {\n", " if (pass_mouse_events)\n", " return fig.mouse_event(event, event['data']);\n", " }\n", "\n", " rubberband.mousedown('button_press', mouse_event_fn);\n", " rubberband.mouseup('button_release', mouse_event_fn);\n", " // Throttle sequential mouse events to 1 every 20ms.\n", " rubberband.mousemove('motion_notify', mouse_event_fn);\n", "\n", " rubberband.mouseenter('figure_enter', mouse_event_fn);\n", " rubberband.mouseleave('figure_leave', mouse_event_fn);\n", "\n", " canvas_div.on(\"wheel\", function (event) {\n", " event = event.originalEvent;\n", " event['data'] = 'scroll'\n", " if (event.deltaY < 0) {\n", " event.step = 1;\n", " } else {\n", " event.step = -1;\n", " }\n", " mouse_event_fn(event);\n", " });\n", "\n", " canvas_div.append(canvas);\n", " canvas_div.append(rubberband);\n", "\n", " this.rubberband = rubberband;\n", " this.rubberband_canvas = rubberband[0];\n", " this.rubberband_context = rubberband[0].getContext(\"2d\");\n", " this.rubberband_context.strokeStyle = \"#000000\";\n", "\n", " this._resize_canvas = function(width, height) {\n", " // Keep the size of the canvas, canvas container, and rubber band\n", " // canvas in synch.\n", " canvas_div.css('width', width)\n", " canvas_div.css('height', height)\n", "\n", " canvas.attr('width', width * mpl.ratio);\n", " canvas.attr('height', height * mpl.ratio);\n", " canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n", "\n", " rubberband.attr('width', width);\n", " rubberband.attr('height', height);\n", " }\n", "\n", " // Set the figure to an initial 600x600px, this will subsequently be updated\n", " // upon first draw.\n", " this._resize_canvas(600, 600);\n", "\n", " // Disable right mouse context menu.\n", " $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n", " return false;\n", " });\n", "\n", " function set_focus () {\n", " canvas.focus();\n", " canvas_div.focus();\n", " }\n", "\n", " window.setTimeout(set_focus, 100);\n", "}\n", "\n", "mpl.figure.prototype._init_toolbar = function() {\n", " var fig = this;\n", "\n", " var nav_element = $('
');\n", " nav_element.attr('style', 'width: 100%');\n", " this.root.append(nav_element);\n", "\n", " // Define a callback function for later on.\n", " function toolbar_event(event) {\n", " return fig.toolbar_button_onclick(event['data']);\n", " }\n", " function toolbar_mouse_event(event) {\n", " return fig.toolbar_button_onmouseover(event['data']);\n", " }\n", "\n", " for(var toolbar_ind in mpl.toolbar_items) {\n", " var name = mpl.toolbar_items[toolbar_ind][0];\n", " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", " var image = mpl.toolbar_items[toolbar_ind][2];\n", " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", "\n", " if (!name) {\n", " // put a spacer in here.\n", " continue;\n", " }\n", " var button = $('');\n", " button.click(method_name, toolbar_event);\n", " button.mouseover(tooltip, toolbar_mouse_event);\n", " nav_element.append(button);\n", " }\n", "\n", " // Add the status bar.\n", " var status_bar = $('');\n", " nav_element.append(status_bar);\n", " this.message = status_bar[0];\n", "\n", " // Add the close button to the window.\n", " var buttongrp = $('
');\n", " var button = $('');\n", " button.click(function (evt) { fig.handle_close(fig, {}); } );\n", " button.mouseover('Stop Interaction', toolbar_mouse_event);\n", " buttongrp.append(button);\n", " var titlebar = this.root.find($('.ui-dialog-titlebar'));\n", " titlebar.prepend(buttongrp);\n", "}\n", "\n", "mpl.figure.prototype._root_extra_style = function(el){\n", " var fig = this\n", " el.on(\"remove\", function(){\n", "\tfig.close_ws(fig, {});\n", " });\n", "}\n", "\n", "mpl.figure.prototype._canvas_extra_style = function(el){\n", " // this is important to make the div 'focusable\n", " el.attr('tabindex', 0)\n", " // reach out to IPython and tell the keyboard manager to turn it's self\n", " // off when our div gets focus\n", "\n", " // location in version 3\n", " if (IPython.notebook.keyboard_manager) {\n", " IPython.notebook.keyboard_manager.register_events(el);\n", " }\n", " else {\n", " // location in version 2\n", " IPython.keyboard_manager.register_events(el);\n", " }\n", "\n", "}\n", "\n", "mpl.figure.prototype._key_event_extra = function(event, name) {\n", " var manager = IPython.notebook.keyboard_manager;\n", " if (!manager)\n", " manager = IPython.keyboard_manager;\n", "\n", " // Check for shift+enter\n", " if (event.shiftKey && event.which == 13) {\n", " this.canvas_div.blur();\n", " event.shiftKey = false;\n", " // Send a \"J\" for go to next cell\n", " event.which = 74;\n", " event.keyCode = 74;\n", " manager.command_mode();\n", " manager.handle_keydown(event);\n", " }\n", "}\n", "\n", "mpl.figure.prototype.handle_save = function(fig, msg) {\n", " fig.ondownload(fig, null);\n", "}\n", "\n", "\n", "mpl.find_output_cell = function(html_output) {\n", " // Return the cell and output element which can be found *uniquely* in the notebook.\n", " // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n", " // IPython event is triggered only after the cells have been serialised, which for\n", " // our purposes (turning an active figure into a static one), is too late.\n", " var cells = IPython.notebook.get_cells();\n", " var ncells = cells.length;\n", " for (var i=0; i= 3 moved mimebundle to data attribute of output\n", " data = data.data;\n", " }\n", " if (data['text/html'] == html_output) {\n", " return [cell, data, j];\n", " }\n", " }\n", " }\n", " }\n", "}\n", "\n", "// Register the function which deals with the matplotlib target/channel.\n", "// The kernel may be null if the page has been refreshed.\n", "if (IPython.notebook.kernel != null) {\n", " IPython.notebook.kernel.comm_manager.register_target('matplotlib', mpl.mpl_figure_comm);\n", "}\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# Traigo las fechas, y las paso a un tipo de dato datetime asi matplotlib lo plotea bien y no hace ruido\n", "dates = [datetime.datetime.strptime(date_str, '%d/%m/%Y %H:%M:%S') for date_str in respuestas.Tiempo.values]\n", "\n", "# Ordeno las fechas por si alguna se mezcló en el camino, y ploteo contra el id.\n", "# en realidad solo necesito que vaya de uno en uno con cada fecha de ingreso\n", "# sería lo mismo hacer algo como:\n", "# plt.plot(sorted(dates), list(range(len(dates))))\n", "\n", "plt.plot(sorted(dates), respuestas.index+1)\n", "plt.xticks(rotation=45) # Arreglo para que no se solapen las horas\n", "plt.ylabel(\"Respuestas al form\")\n", "plt.grid()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "---\n", "---\n", "Algo menos trivial sería ver como es el solape de inscripciones, para saber como distribuirnos los docentes los horarios. Si hay mucha gente a la mañana habrá que poner más gente en ese turno. Pero también es importante saber cuanta gente se anotó a mas de un turno, porque quizás se podría eliminar alguno de los turnos y distribuir a esa gente en los otros.\n", "\n", "Una rudimentaria forma de hacerlo sería recorrer cada uno de los dias y horarios para cada alumno e ir almacenando la id de ese alumno, cosa de que poder ver fácilmente quien se anotó a qué dia y horario" ] }, { "cell_type": "code", "execution_count": 153, "metadata": {}, "outputs": [], "source": [ "dias = respuestas.columns[1:6].values\n", "solape = {}\n", "turnos = ['Man', 'Tar', 'Noc', 'None']\n", "\n", "# Solape va a ser un diccionario con 5 entradas (una por cada dia)\n", "# cada entrada va a tener otras tres (una por cada turno)\n", "# y ahi guardaremos el id de la persona que se anotó a ese dia y horario\n", "#\n", "# Sería una cosa:\n", "# Lun:\n", "# Man: {Persona1, ...}\n", "# Tar: {Persona25, ...}\n", "# Noc: {...}\n", "# None: {...}\n", "#\n", "# idem con los demas días\n", "#\n", "# Primero entonces inicializo todo vacio, pero para que ya esté la estructura armada\n", "for dia in dias: solape[dia] = {turn:set() for turn in turnos}\n", "\n", "for index, fila in respuestas.iterrows(): # recorro todas las filas\n", " for dia in dias: # recorro todos los dias (que son las columnas 1:6)\n", " for turno in fila[dia].split(\", \"): # Aca me fijo y separo todos los dias que se anotó la persona\n", " solape[dia][turno].add(str(index)) # agrego a la persona a cada dia y turno apropiado" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Ahora tenemos en `solape` todo distribuido ya con las personas ordenadas en los dias y turnos que eligió. Para ver efectivamente el solapamiento de horarios podemos ver la interseccion de cada set, justamente por este motivo es que elegimos usar un set, para poder intersecar fácilmente." ] }, { "cell_type": "code", "execution_count": 154, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Lun:\n", " \t Man\tTar\tNoc\tNone\n", "Man\t76\t35\t21\t0\t\n", "Tar\t35\t68\t21\t0\t\n", "Noc\t21\t21\t68\t0\t\n", "None\t0\t0\t0\t20\t\n", "\n", "\n", "\n", "Mar:\n", " \t Man\tTar\tNoc\tNone\n", "Man\t76\t38\t21\t0\t\n", "Tar\t38\t76\t24\t0\t\n", "Noc\t21\t24\t67\t0\t\n", "None\t0\t0\t0\t18\t\n", "\n", "\n", "\n", "Mie:\n", " \t Man\tTar\tNoc\tNone\n", "Man\t80\t40\t20\t0\t\n", "Tar\t40\t76\t23\t0\t\n", "Noc\t20\t23\t64\t0\t\n", "None\t0\t0\t0\t17\t\n", "\n", "\n", "\n", "Jue:\n", " \t Man\tTar\tNoc\tNone\n", "Man\t72\t37\t22\t0\t\n", "Tar\t37\t71\t21\t0\t\n", "Noc\t22\t21\t65\t0\t\n", "None\t0\t0\t0\t25\t\n", "\n", "\n", "\n", "Vie:\n", " \t Man\tTar\tNoc\tNone\n", "Man\t84\t47\t28\t0\t\n", "Tar\t47\t84\t31\t0\t\n", "Noc\t28\t31\t68\t0\t\n", "None\t0\t0\t0\t17\t\n", "\n", "\n", "\n" ] } ], "source": [ "for dia in dias: # Voy a armar una \"matriz de solape\" por dia\n", " print(f\"{dia}:\")\n", " print(\" \\t\",\"\\t\".join(turnos)) # Esta es la primer fila con los nombre de los turnos\n", " for turno_i in turnos:\n", " print(turno_i, end='\\t') # La primer columna con nombres de turnos\n", " for turno_j in turnos: \n", " # Aca interseco los dos sets con `&` y luego me fijo el largo del set\n", " # como son sets, no tengo que preocuparme por doble conteos nunca!!\n", " interseccion = len(solape[dia][turno_i] & solape[dia][turno_j])\n", " print(f\"{interseccion}\", end='\\t') # printeo el valor y meto un tab\n", " print(\"\") # agrego una linea en blanco\n", " print(\"\\n\\n\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Y bueno, así de fácil (fácil?) se pudo saber como es la distribución de inscriptos en cada horario, y cómo fue el solapamiento de turnos. Obvio que esto tambien se podría visualizar en un heatmap, o algo por el estilo, pero todas esas cosas extra se las dejamos para ustedes para experimentar.\n", "\n", "Esto puede parecer al pedo, pero quizas está bueno por si realmente se decide en base a estos datos sacar un turno. Por ejemplo, si se decide eliminar el turno tarde del Lunes, se le podría enviar un mail a aquellos que se anotaron a la tarde y noche, pidiendoles que se anoten de noche, y a los que se anotaron mañana-tarde que se anoten a la mañana!\n", "\n", "Abajo les dejamos eso hecho con el id del inscripto. El formulario tambien nos dice a nosotros sus mails, pero no divulgaríamos esa informacion! De cualquier manera el procedimiento sería el mismo, salvo que al final printeariamos los mails de forma tal de luego poder copiar y pegarlos y enviarles el mail a todos juntos." ] }, { "cell_type": "code", "execution_count": 194, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
TiempoLunMarMieJueVieNivelExtras
329/03/2020 18:22:11Man, Tar, NocMan, Tar, NocMan, Tar, NocMan, Tar, NocMan, Tar, Noc3Programación orientada a objetos
1729/03/2020 21:46:11Man, Tar, NocMan, Tar, NocMan, Tar, NocMan, Tar, NocMan, Tar, Noc5NaN
2129/03/2020 22:51:49Man, TarNoneMan, TarMan, TarMan, Tar1NaN
2630/03/2020 04:35:31Man, Tar, NocMan, Tar, NocMan, Tar, NocMan, Tar, NocMan, Tar, Noc2NaN
2830/03/2020 09:26:26Man, Tar, NocManManMan, Tar, NocMan, Tar, Noc7NaN
3530/03/2020 12:44:55Man, Tar, NocMan, Tar, NocMan, Tar, NocMan, Tar, NocMan, Tar, Noc3Animaciones
4030/03/2020 16:34:50Man, TarMan, TarMan, TarMan, TarMan, Tar3NaN
4331/03/2020 08:34:47Man, TarMan, TarMan, TarMan, TarMan, Tar5NaN
5001/04/2020 00:11:25Man, TarMan, TarMan, TarMan, TarMan, Tar3NaN
5301/04/2020 00:30:13Man, TarMan, TarMan, TarMan, TarMan, Tar1NaN
5501/04/2020 00:33:26Man, Tar, NocMan, Tar, NocMan, Tar, NocMan, Tar, NocMan, Tar, Noc1NaN
6301/04/2020 02:42:35Man, Tar, NocNoneMan, Tar, NocNoneMan, Tar, Noc3Importar txt y que python lo interprete como u...
7201/04/2020 10:54:46Man, TarMan, TarTarMan, TarMan, Tar7NaN
7601/04/2020 11:35:54Man, TarMan, TarMan, TarMan, TarMan, Tar1NaN
7701/04/2020 11:40:01Man, TarMan, TarMan, TarMan, TarMan, Tar5Ahroa estoy metiendome con netCDF4 y xArray pa...
7801/04/2020 11:52:56Man, Tar, NocNoneMan, Tar, NocNoneMan, Tar, Noc2panda
8101/04/2020 13:15:16Man, TarMan, TarMan, TarMan, TarMan, Tar1NaN
8501/04/2020 13:47:41Man, TarMan, TarMan, TarMan, TarMan, Tar3NaN
8701/04/2020 14:21:19Man, Tar, NocMan, Tar, NocMan, Tar, NocMan, Tar, NocMan, Tar, Noc2NaN
9901/04/2020 15:49:05Man, Tar, NocNoneTarNoneTar, Noc1NaN
10001/04/2020 15:55:30Man, TarMan, TarMan, TarMan, TarMan, Tar2NaN
10101/04/2020 16:10:48Man, TarMan, TarMan, TarMan, TarMan, Tar2NaN
10301/04/2020 16:19:01Man, TarMan, TarMan, TarMan, TarMan, Tar1NaN
10501/04/2020 16:29:33Man, Tar, NocNoneNocNoneNone1NaN
11201/04/2020 19:06:56Man, Tar, NocMan, Tar, NocMan, Tar, NocMan, Tar, NocMan, Tar, Noc2NaN
11301/04/2020 19:08:07Man, Tar, NocMan, Tar, NocMan, Tar, NocMan, Tar, NocTar, Noc2NaN
12401/04/2020 21:31:27Man, TarManMan, TarNoneNone1NaN
12901/04/2020 23:22:27Man, Tar, NocNoneMan, Tar, NocNoneMan, Tar, Noc4NaN
13402/04/2020 03:40:22Man, TarMan, TarMan, TarMan, TarMan, Tar7NaN
13602/04/2020 04:25:40Man, TarMan, TarMan, TarMan, TarMan, Tar1Html
13702/04/2020 10:54:04Man, TarMan, TarMan, TarMan, TarMan, Tar5genomica
14202/04/2020 12:34:15Man, TarNoneMan, TarNoneMan, Tar, Noc2numpy
14702/04/2020 14:10:59Man, Tar, NocTar, NocMan, Tar, NocNocMan, Tar, Noc1NaN
15402/04/2020 20:13:32Man, TarMan, TarMan, TarManMan, Tar, Noc2NaN
16103/04/2020 11:47:59Man, Tar, NocMan, Tar, NocMan, Tar, NocMan, Tar, NocMan, Tar, Noc5NaN
\n", "
" ], "text/plain": [ " Tiempo Lun Mar Mie \\\n", "3 29/03/2020 18:22:11 Man, Tar, Noc Man, Tar, Noc Man, Tar, Noc \n", "17 29/03/2020 21:46:11 Man, Tar, Noc Man, Tar, Noc Man, Tar, Noc \n", "21 29/03/2020 22:51:49 Man, Tar None Man, Tar \n", "26 30/03/2020 04:35:31 Man, Tar, Noc Man, Tar, Noc Man, Tar, Noc \n", "28 30/03/2020 09:26:26 Man, Tar, Noc Man Man \n", "35 30/03/2020 12:44:55 Man, Tar, Noc Man, Tar, Noc Man, Tar, Noc \n", "40 30/03/2020 16:34:50 Man, Tar Man, Tar Man, Tar \n", "43 31/03/2020 08:34:47 Man, Tar Man, Tar Man, Tar \n", "50 01/04/2020 00:11:25 Man, Tar Man, Tar Man, Tar \n", "53 01/04/2020 00:30:13 Man, Tar Man, Tar Man, Tar \n", "55 01/04/2020 00:33:26 Man, Tar, Noc Man, Tar, Noc Man, Tar, Noc \n", "63 01/04/2020 02:42:35 Man, Tar, Noc None Man, Tar, Noc \n", "72 01/04/2020 10:54:46 Man, Tar Man, Tar Tar \n", "76 01/04/2020 11:35:54 Man, Tar Man, Tar Man, Tar \n", "77 01/04/2020 11:40:01 Man, Tar Man, Tar Man, Tar \n", "78 01/04/2020 11:52:56 Man, Tar, Noc None Man, Tar, Noc \n", "81 01/04/2020 13:15:16 Man, Tar Man, Tar Man, Tar \n", "85 01/04/2020 13:47:41 Man, Tar Man, Tar Man, Tar \n", "87 01/04/2020 14:21:19 Man, Tar, Noc Man, Tar, Noc Man, Tar, Noc \n", "99 01/04/2020 15:49:05 Man, Tar, Noc None Tar \n", "100 01/04/2020 15:55:30 Man, Tar Man, Tar Man, Tar \n", "101 01/04/2020 16:10:48 Man, Tar Man, Tar Man, Tar \n", "103 01/04/2020 16:19:01 Man, Tar Man, Tar Man, Tar \n", "105 01/04/2020 16:29:33 Man, Tar, Noc None Noc \n", "112 01/04/2020 19:06:56 Man, Tar, Noc Man, Tar, Noc Man, Tar, Noc \n", "113 01/04/2020 19:08:07 Man, Tar, Noc Man, Tar, Noc Man, Tar, Noc \n", "124 01/04/2020 21:31:27 Man, Tar Man Man, Tar \n", "129 01/04/2020 23:22:27 Man, Tar, Noc None Man, Tar, Noc \n", "134 02/04/2020 03:40:22 Man, Tar Man, Tar Man, Tar \n", "136 02/04/2020 04:25:40 Man, Tar Man, Tar Man, Tar \n", "137 02/04/2020 10:54:04 Man, Tar Man, Tar Man, Tar \n", "142 02/04/2020 12:34:15 Man, Tar None Man, Tar \n", "147 02/04/2020 14:10:59 Man, Tar, Noc Tar, Noc Man, Tar, Noc \n", "154 02/04/2020 20:13:32 Man, Tar Man, Tar Man, Tar \n", "161 03/04/2020 11:47:59 Man, Tar, Noc Man, Tar, Noc Man, Tar, Noc \n", "\n", " Jue Vie Nivel \\\n", "3 Man, Tar, Noc Man, Tar, Noc 3 \n", "17 Man, Tar, Noc Man, Tar, Noc 5 \n", "21 Man, Tar Man, Tar 1 \n", "26 Man, Tar, Noc Man, Tar, Noc 2 \n", "28 Man, Tar, Noc Man, Tar, Noc 7 \n", "35 Man, Tar, Noc Man, Tar, Noc 3 \n", "40 Man, Tar Man, Tar 3 \n", "43 Man, Tar Man, Tar 5 \n", "50 Man, Tar Man, Tar 3 \n", "53 Man, Tar Man, Tar 1 \n", "55 Man, Tar, Noc Man, Tar, Noc 1 \n", "63 None Man, Tar, Noc 3 \n", "72 Man, Tar Man, Tar 7 \n", "76 Man, Tar Man, Tar 1 \n", "77 Man, Tar Man, Tar 5 \n", "78 None Man, Tar, Noc 2 \n", "81 Man, Tar Man, Tar 1 \n", "85 Man, Tar Man, Tar 3 \n", "87 Man, Tar, Noc Man, Tar, Noc 2 \n", "99 None Tar, Noc 1 \n", "100 Man, Tar Man, Tar 2 \n", "101 Man, Tar Man, Tar 2 \n", "103 Man, Tar Man, Tar 1 \n", "105 None None 1 \n", "112 Man, Tar, Noc Man, Tar, Noc 2 \n", "113 Man, Tar, Noc Tar, Noc 2 \n", "124 None None 1 \n", "129 None Man, Tar, Noc 4 \n", "134 Man, Tar Man, Tar 7 \n", "136 Man, Tar Man, Tar 1 \n", "137 Man, Tar Man, Tar 5 \n", "142 None Man, Tar, Noc 2 \n", "147 Noc Man, Tar, Noc 1 \n", "154 Man Man, Tar, Noc 2 \n", "161 Man, Tar, Noc Man, Tar, Noc 5 \n", "\n", " Extras \n", "3 Programación orientada a objetos \n", "17 NaN \n", "21 NaN \n", "26 NaN \n", "28 NaN \n", "35 Animaciones \n", "40 NaN \n", "43 NaN \n", "50 NaN \n", "53 NaN \n", "55 NaN \n", "63 Importar txt y que python lo interprete como u... \n", "72 NaN \n", "76 NaN \n", "77 Ahroa estoy metiendome con netCDF4 y xArray pa... \n", "78 panda \n", "81 NaN \n", "85 NaN \n", "87 NaN \n", "99 NaN \n", "100 NaN \n", "101 NaN \n", "103 NaN \n", "105 NaN \n", "112 NaN \n", "113 NaN \n", "124 NaN \n", "129 NaN \n", "134 NaN \n", "136 Html \n", "137 genomica \n", "142 numpy \n", "147 NaN \n", "154 NaN \n", "161 NaN " ] }, "execution_count": 194, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gente_man_tar = respuestas.loc[(respuestas.Lun == 'Man, Tar')]\n", "gente_man_tar\n", "# Aca si estuviera el campo Email podriamos hacer\n", "# print(gente_man_tar[Email])\n", "# Y mandarles el mail" ] } ], "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.7.3" } }, "nbformat": 4, "nbformat_minor": 2 }