Skip to content

Instantly share code, notes, and snippets.

@jairot
Forked from mgaitan/stafe.ipynb
Last active August 29, 2015 14:23
Show Gist options
  • Save jairot/0e9b5d79f6c59cded0c1 to your computer and use it in GitHub Desktop.
Save jairot/0e9b5d79f6c59cded0c1 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Proyección de votos en las mesas no escrutadas durante el escrutinio provisorio\n",
"\n",
"En el escrutinio provisorio realizado en la provincia de Santa Fe quedaron sin escrutar 347 mesas. \n",
"\n",
"* 304 telegramas fueron desestimados.\n",
"* 33 mesas no fueron cargadas.\n",
"\n",
"Desde Opendata Córdoba intentamos proyectar los resultados de las mesas ya escrutadas, sobre estas mesas sin escrutar para tratar de predecir que puede pasar en el recuento definitivo."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Obtención de datos\n",
"\n",
"El gobierno de la provincia de Santa Fe provee los datos actualizados del escrutinio provisorio en csv.\n",
"\n",
"Los descargamos desde http://elecciones.santafe.gov.ar/descargas"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"--2015-06-16 11:41:29-- http://elecciones.santafe.gov.ar/bundles/escrutinio/descargas/csv.zip\n",
"Resolviendo elecciones.santafe.gov.ar (elecciones.santafe.gov.ar)... 200.12.192.183\n",
"Conectando con elecciones.santafe.gov.ar (elecciones.santafe.gov.ar)[200.12.192.183]:80... conectado.\n",
"Petición HTTP enviada, esperando respuesta... 200 OK\n",
"Longitud: 865821 (846K) [application/zip]\n",
"Grabando a: “csv.zip”\n",
"\n",
"100%[======================================>] 865.821 725K/s en 1,2s \n",
"\n",
"2015-06-16 11:41:30 (725 KB/s) - “csv.zip” guardado [865821/865821]\n",
"\n"
]
}
],
"source": [
"!wget http://elecciones.santafe.gov.ar/bundles/escrutinio/descargas/csv.zip"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Archive: csv.zip\n",
" inflating: desestimados.csv \n",
" inflating: pendientes.csv \n",
" inflating: computados.csv \n"
]
}
],
"source": [
"!unzip csv.zip"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Preparación del dataset\n",
"\n",
"Usando pandas preparamos los datos."
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/jtrad/play/stats/local/lib/python2.7/site-packages/pandas/io/parsers.py:1170: DtypeWarning: Columns (6) have mixed types. Specify dtype option on import or set low_memory=False.\n",
" data = self._reader.read(nrows)\n"
]
}
],
"source": [
"computados = pd.read_csv('computados.csv')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Votos promedio por seccion y partido \n",
"\n",
"Calculamos los votos de una mesa \"Promedio\" por cada seccion, solo los partidos con mas de 5 votos."
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th></th>\n",
" <th>votosGob</th>\n",
" </tr>\n",
" <tr>\n",
" <th>nroSeccion</th>\n",
" <th>nroPartido</th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th rowspan=\"6\" valign=\"top\">1</th>\n",
" <th>0004</th>\n",
" <td>60.518519</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0005</th>\n",
" <td>101.009259</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0006</th>\n",
" <td>71.370370</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0008</th>\n",
" <td>6.388889</td>\n",
" </tr>\n",
" <tr>\n",
" <th>ANUL</th>\n",
" <td>5.240741</td>\n",
" </tr>\n",
" <tr>\n",
" <th>BLAN</th>\n",
" <td>11.814815</td>\n",
" </tr>\n",
" <tr>\n",
" <th rowspan=\"6\" valign=\"top\">2</th>\n",
" <th>0004</th>\n",
" <td>50.153488</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0005</th>\n",
" <td>91.911628</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0006</th>\n",
" <td>72.748837</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0008</th>\n",
" <td>9.093023</td>\n",
" </tr>\n",
" <tr>\n",
" <th>ANUL</th>\n",
" <td>6.967442</td>\n",
" </tr>\n",
" <tr>\n",
" <th>BLAN</th>\n",
" <td>12.627907</td>\n",
" </tr>\n",
" <tr>\n",
" <th rowspan=\"6\" valign=\"top\">3</th>\n",
" <th>0004</th>\n",
" <td>90.985542</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0005</th>\n",
" <td>70.127711</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0006</th>\n",
" <td>57.987952</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0008</th>\n",
" <td>6.669880</td>\n",
" </tr>\n",
" <tr>\n",
" <th>ANUL</th>\n",
" <td>6.067470</td>\n",
" </tr>\n",
" <tr>\n",
" <th>BLAN</th>\n",
" <td>7.115663</td>\n",
" </tr>\n",
" <tr>\n",
" <th rowspan=\"6\" valign=\"top\">4</th>\n",
" <th>0004</th>\n",
" <td>67.569444</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0005</th>\n",
" <td>74.245370</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0006</th>\n",
" <td>73.532407</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0008</th>\n",
" <td>8.648148</td>\n",
" </tr>\n",
" <tr>\n",
" <th>ANUL</th>\n",
" <td>5.773148</td>\n",
" </tr>\n",
" <tr>\n",
" <th>BLAN</th>\n",
" <td>11.504630</td>\n",
" </tr>\n",
" <tr>\n",
" <th rowspan=\"6\" valign=\"top\">5</th>\n",
" <th>0004</th>\n",
" <td>73.037037</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0005</th>\n",
" <td>79.870370</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0006</th>\n",
" <td>52.777778</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0008</th>\n",
" <td>6.240741</td>\n",
" </tr>\n",
" <tr>\n",
" <th>ANUL</th>\n",
" <td>5.259259</td>\n",
" </tr>\n",
" <tr>\n",
" <th>BLAN</th>\n",
" <td>15.055556</td>\n",
" </tr>\n",
" <tr>\n",
" <th rowspan=\"5\" valign=\"top\">6</th>\n",
" <th>0004</th>\n",
" <td>55.075107</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0005</th>\n",
" <td>82.152361</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0006</th>\n",
" <td>83.175966</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0008</th>\n",
" <td>7.437768</td>\n",
" </tr>\n",
" <tr>\n",
" <th>BLAN</th>\n",
" <td>10.976395</td>\n",
" </tr>\n",
" <tr>\n",
" <th rowspan=\"6\" valign=\"top\">7</th>\n",
" <th>0004</th>\n",
" <td>73.019608</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0005</th>\n",
" <td>65.223039</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0006</th>\n",
" <td>83.588235</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0008</th>\n",
" <td>7.387255</td>\n",
" </tr>\n",
" <tr>\n",
" <th>ANUL</th>\n",
" <td>5.105392</td>\n",
" </tr>\n",
" <tr>\n",
" <th>BLAN</th>\n",
" <td>11.526961</td>\n",
" </tr>\n",
" <tr>\n",
" <th rowspan=\"6\" valign=\"top\">8</th>\n",
" <th>0004</th>\n",
" <td>59.910714</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0005</th>\n",
" <td>89.434524</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0006</th>\n",
" <td>72.172619</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0008</th>\n",
" <td>7.369048</td>\n",
" </tr>\n",
" <tr>\n",
" <th>ANUL</th>\n",
" <td>6.732143</td>\n",
" </tr>\n",
" <tr>\n",
" <th>BLAN</th>\n",
" <td>11.172619</td>\n",
" </tr>\n",
" <tr>\n",
" <th rowspan=\"7\" valign=\"top\">9</th>\n",
" <th>0001</th>\n",
" <td>5.849754</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0004</th>\n",
" <td>80.976601</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0005</th>\n",
" <td>72.028325</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0006</th>\n",
" <td>69.038177</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0008</th>\n",
" <td>11.842365</td>\n",
" </tr>\n",
" <tr>\n",
" <th>ANUL</th>\n",
" <td>9.296798</td>\n",
" </tr>\n",
" <tr>\n",
" <th>BLAN</th>\n",
" <td>5.490148</td>\n",
" </tr>\n",
" <tr>\n",
" <th rowspan=\"6\" valign=\"top\">10</th>\n",
" <th>0004</th>\n",
" <td>84.262658</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0005</th>\n",
" <td>81.088608</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0006</th>\n",
" <td>57.829114</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0008</th>\n",
" <td>9.231013</td>\n",
" </tr>\n",
" <tr>\n",
" <th>ANUL</th>\n",
" <td>8.468354</td>\n",
" </tr>\n",
" <tr>\n",
" <th>BLAN</th>\n",
" <td>6.797468</td>\n",
" </tr>\n",
" <tr>\n",
" <th rowspan=\"6\" valign=\"top\">11</th>\n",
" <th>0004</th>\n",
" <td>64.423664</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0005</th>\n",
" <td>84.377863</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0006</th>\n",
" <td>68.610687</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0008</th>\n",
" <td>8.274809</td>\n",
" </tr>\n",
" <tr>\n",
" <th>ANUL</th>\n",
" <td>5.267176</td>\n",
" </tr>\n",
" <tr>\n",
" <th>BLAN</th>\n",
" <td>10.034351</td>\n",
" </tr>\n",
" <tr>\n",
" <th rowspan=\"5\" valign=\"top\">12</th>\n",
" <th>0004</th>\n",
" <td>69.859155</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0005</th>\n",
" <td>84.183099</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0006</th>\n",
" <td>51.014085</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0008</th>\n",
" <td>7.591549</td>\n",
" </tr>\n",
" <tr>\n",
" <th>BLAN</th>\n",
" <td>18.281690</td>\n",
" </tr>\n",
" <tr>\n",
" <th rowspan=\"6\" valign=\"top\">13</th>\n",
" <th>0001</th>\n",
" <td>9.826156</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0004</th>\n",
" <td>51.103668</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0005</th>\n",
" <td>66.385965</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0006</th>\n",
" <td>101.730463</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0008</th>\n",
" <td>10.357257</td>\n",
" </tr>\n",
" <tr>\n",
" <th>ANUL</th>\n",
" <td>6.835726</td>\n",
" </tr>\n",
" <tr>\n",
" <th rowspan=\"7\" valign=\"top\">14</th>\n",
" <th>0001</th>\n",
" <td>9.798171</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0004</th>\n",
" <td>70.072502</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0005</th>\n",
" <td>63.915741</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0006</th>\n",
" <td>77.970607</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0008</th>\n",
" <td>11.160026</td>\n",
" </tr>\n",
" <tr>\n",
" <th>ANUL</th>\n",
" <td>11.238406</td>\n",
" </tr>\n",
" <tr>\n",
" <th>BLAN</th>\n",
" <td>6.130634</td>\n",
" </tr>\n",
" <tr>\n",
" <th rowspan=\"7\" valign=\"top\">15</th>\n",
" <th>0001</th>\n",
" <td>6.252874</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0004</th>\n",
" <td>79.022989</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0005</th>\n",
" <td>76.100164</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0006</th>\n",
" <td>71.533662</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0008</th>\n",
" <td>8.522167</td>\n",
" </tr>\n",
" <tr>\n",
" <th>ANUL</th>\n",
" <td>9.591133</td>\n",
" </tr>\n",
" <tr>\n",
" <th>BLAN</th>\n",
" <td>8.558292</td>\n",
" </tr>\n",
" <tr>\n",
" <th rowspan=\"4\" valign=\"top\">16</th>\n",
" <th>0004</th>\n",
" <td>69.158192</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0005</th>\n",
" <td>64.683616</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0006</th>\n",
" <td>75.553672</td>\n",
" </tr>\n",
" <tr>\n",
" <th>BLAN</th>\n",
" <td>13.045198</td>\n",
" </tr>\n",
" <tr>\n",
" <th rowspan=\"5\" valign=\"top\">17</th>\n",
" <th>0004</th>\n",
" <td>79.886076</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0005</th>\n",
" <td>65.759494</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0006</th>\n",
" <td>69.873418</td>\n",
" </tr>\n",
" <tr>\n",
" <th>ANUL</th>\n",
" <td>6.177215</td>\n",
" </tr>\n",
" <tr>\n",
" <th>BLAN</th>\n",
" <td>16.746835</td>\n",
" </tr>\n",
" <tr>\n",
" <th rowspan=\"6\" valign=\"top\">18</th>\n",
" <th>0004</th>\n",
" <td>72.791262</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0005</th>\n",
" <td>79.509709</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0006</th>\n",
" <td>62.140777</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0008</th>\n",
" <td>6.577670</td>\n",
" </tr>\n",
" <tr>\n",
" <th>ANUL</th>\n",
" <td>6.165049</td>\n",
" </tr>\n",
" <tr>\n",
" <th>BLAN</th>\n",
" <td>11.941748</td>\n",
" </tr>\n",
" <tr>\n",
" <th rowspan=\"5\" valign=\"top\">19</th>\n",
" <th>0004</th>\n",
" <td>57.773913</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0005</th>\n",
" <td>80.600000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0006</th>\n",
" <td>61.939130</td>\n",
" </tr>\n",
" <tr>\n",
" <th>ANUL</th>\n",
" <td>5.234783</td>\n",
" </tr>\n",
" <tr>\n",
" <th>BLAN</th>\n",
" <td>8.991304</td>\n",
" </tr>\n",
" <tr>\n",
" <th rowspan=\"7\" valign=\"top\">20</th>\n",
" <th>0001</th>\n",
" <td>5.508951</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0004</th>\n",
" <td>84.250639</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0005</th>\n",
" <td>76.074169</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0006</th>\n",
" <td>72.913043</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0008</th>\n",
" <td>7.312020</td>\n",
" </tr>\n",
" <tr>\n",
" <th>ANUL</th>\n",
" <td>7.797954</td>\n",
" </tr>\n",
" <tr>\n",
" <th>BLAN</th>\n",
" <td>7.959079</td>\n",
" </tr>\n",
" <tr>\n",
" <th rowspan=\"6\" valign=\"top\">21</th>\n",
" <th>0004</th>\n",
" <td>53.357576</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0005</th>\n",
" <td>100.236364</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0006</th>\n",
" <td>61.927273</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0008</th>\n",
" <td>6.072727</td>\n",
" </tr>\n",
" <tr>\n",
" <th>ANUL</th>\n",
" <td>6.278788</td>\n",
" </tr>\n",
" <tr>\n",
" <th>BLAN</th>\n",
" <td>12.684848</td>\n",
" </tr>\n",
" <tr>\n",
" <th rowspan=\"5\" valign=\"top\">22</th>\n",
" <th>0004</th>\n",
" <td>69.725926</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0005</th>\n",
" <td>71.014815</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0006</th>\n",
" <td>51.992593</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0008</th>\n",
" <td>6.392593</td>\n",
" </tr>\n",
" <tr>\n",
" <th>BLAN</th>\n",
" <td>13.888889</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" votosGob\n",
"nroSeccion nroPartido \n",
"1 0004 60.518519\n",
" 0005 101.009259\n",
" 0006 71.370370\n",
" 0008 6.388889\n",
" ANUL 5.240741\n",
" BLAN 11.814815\n",
"2 0004 50.153488\n",
" 0005 91.911628\n",
" 0006 72.748837\n",
" 0008 9.093023\n",
" ANUL 6.967442\n",
" BLAN 12.627907\n",
"3 0004 90.985542\n",
" 0005 70.127711\n",
" 0006 57.987952\n",
" 0008 6.669880\n",
" ANUL 6.067470\n",
" BLAN 7.115663\n",
"4 0004 67.569444\n",
" 0005 74.245370\n",
" 0006 73.532407\n",
" 0008 8.648148\n",
" ANUL 5.773148\n",
" BLAN 11.504630\n",
"5 0004 73.037037\n",
" 0005 79.870370\n",
" 0006 52.777778\n",
" 0008 6.240741\n",
" ANUL 5.259259\n",
" BLAN 15.055556\n",
"6 0004 55.075107\n",
" 0005 82.152361\n",
" 0006 83.175966\n",
" 0008 7.437768\n",
" BLAN 10.976395\n",
"7 0004 73.019608\n",
" 0005 65.223039\n",
" 0006 83.588235\n",
" 0008 7.387255\n",
" ANUL 5.105392\n",
" BLAN 11.526961\n",
"8 0004 59.910714\n",
" 0005 89.434524\n",
" 0006 72.172619\n",
" 0008 7.369048\n",
" ANUL 6.732143\n",
" BLAN 11.172619\n",
"9 0001 5.849754\n",
" 0004 80.976601\n",
" 0005 72.028325\n",
" 0006 69.038177\n",
" 0008 11.842365\n",
" ANUL 9.296798\n",
" BLAN 5.490148\n",
"10 0004 84.262658\n",
" 0005 81.088608\n",
" 0006 57.829114\n",
" 0008 9.231013\n",
" ANUL 8.468354\n",
" BLAN 6.797468\n",
"11 0004 64.423664\n",
" 0005 84.377863\n",
" 0006 68.610687\n",
" 0008 8.274809\n",
" ANUL 5.267176\n",
" BLAN 10.034351\n",
"12 0004 69.859155\n",
" 0005 84.183099\n",
" 0006 51.014085\n",
" 0008 7.591549\n",
" BLAN 18.281690\n",
"13 0001 9.826156\n",
" 0004 51.103668\n",
" 0005 66.385965\n",
" 0006 101.730463\n",
" 0008 10.357257\n",
" ANUL 6.835726\n",
"14 0001 9.798171\n",
" 0004 70.072502\n",
" 0005 63.915741\n",
" 0006 77.970607\n",
" 0008 11.160026\n",
" ANUL 11.238406\n",
" BLAN 6.130634\n",
"15 0001 6.252874\n",
" 0004 79.022989\n",
" 0005 76.100164\n",
" 0006 71.533662\n",
" 0008 8.522167\n",
" ANUL 9.591133\n",
" BLAN 8.558292\n",
"16 0004 69.158192\n",
" 0005 64.683616\n",
" 0006 75.553672\n",
" BLAN 13.045198\n",
"17 0004 79.886076\n",
" 0005 65.759494\n",
" 0006 69.873418\n",
" ANUL 6.177215\n",
" BLAN 16.746835\n",
"18 0004 72.791262\n",
" 0005 79.509709\n",
" 0006 62.140777\n",
" 0008 6.577670\n",
" ANUL 6.165049\n",
" BLAN 11.941748\n",
"19 0004 57.773913\n",
" 0005 80.600000\n",
" 0006 61.939130\n",
" ANUL 5.234783\n",
" BLAN 8.991304\n",
"20 0001 5.508951\n",
" 0004 84.250639\n",
" 0005 76.074169\n",
" 0006 72.913043\n",
" 0008 7.312020\n",
" ANUL 7.797954\n",
" BLAN 7.959079\n",
"21 0004 53.357576\n",
" 0005 100.236364\n",
" 0006 61.927273\n",
" 0008 6.072727\n",
" ANUL 6.278788\n",
" BLAN 12.684848\n",
"22 0004 69.725926\n",
" 0005 71.014815\n",
" 0006 51.992593\n",
" 0008 6.392593\n",
" BLAN 13.888889"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pd.set_option('display.max_rows', 2000)\n",
"promedio_gob_seccion = pd.pivot_table(computados, index=['nroSeccion', 'nroPartido'], values=['votosGob']) \n",
"votos_promedio_seccion = promedio_gob_seccion[promedio_gob_seccion.votosGob > 5]\n",
"votos_promedio_seccion"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Mesas desestimadas y pendientes por seccion\n",
"\n",
"Contamos cuantas mesas sin escrutar quedaron por sección"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"desestimados= pd.read_csv('desestimados.csv')\n",
"mesas_desestimadas_por_seccion = desestimados[\"nroSeccion\"].value_counts()"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"pendientes = pd.read_csv('pendientes.csv')\n",
"mesas_pendientes_por_seccion = pendientes[\"nroseccion\"].value_counts()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Performance Partidos en Secciones con mesas Desestimadas\n",
"\n",
"Filtramos por los partidos políticos más importantes:"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"nombrePartido\n",
"FRENTE PROGRESISTA CIVICO Y SOCIAL 74.262837\n",
"UNION PRO FEDERAL 73.118141\n",
"FRENTE JUSTICIALISTA PARA LA VICTORIA 70.905297\n",
"Votos en Blanco 8.267443\n",
"Votos Anulados 7.793253\n",
"Name: votosGob, dtype: float64"
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"computados = computados[computados.nroPartido.isin(['0004','0005','0006','ANUL','BLAN'])]\n",
"secciones_con_mesas_desestimadas = desestimados[\"nroSeccion\"].unique()\n",
"computados_en_secciones_con_mesas_desestimadas = computados[computados.nroSeccion.isin(secciones_con_mesas_desestimadas)]\n",
"computados_en_secciones_con_mesas_desestimadas.groupby('nombrePartido').votosGob.mean().order(ascending=False)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"En promedio, en las secciones con **mesas desestimadas**, el FRENTE PROGRESISTA CIVICO Y SOCIAL tiene **1.15 votos** más que UNION PRO FEDERAL. Lo Cual, si se mantuviera la tendencia, el FRENTE PROGRESISTA CIVICO Y SOCIAL mantendría la ventaja."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Performance Partidos en Secciones con mesas Pendientes"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"nombrePartido\n",
"FRENTE PROGRESISTA CIVICO Y SOCIAL 74.540892\n",
"UNION PRO FEDERAL 72.365472\n",
"FRENTE JUSTICIALISTA PARA LA VICTORIA 71.884418\n",
"Votos en Blanco 8.015801\n",
"Votos Anulados 7.926116\n",
"Name: votosGob, dtype: float64"
]
},
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"computados = computados[computados.nroPartido.isin(['0004','0005','0006','ANUL','BLAN'])]\n",
"secciones_con_mesas_pendientes = pendientes[\"nroseccion\"].unique()\n",
"computados_en_secciones_con_mesas_pendientes = computados[computados.nroSeccion.isin(secciones_con_mesas_pendientes)]\n",
"computados_en_secciones_con_mesas_pendientes.groupby('nombrePartido').votosGob.mean().order(ascending=False)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"En promedio, en las secciones con mesas **pendientes**, el FRENTE PROGRESISTA CIVICO Y SOCIAL tiene **2.18 votos** más que UNION PRO FEDERAL. Lo Cual, si se mantuviera la tendencia, el FRENTE PROGRESISTA CIVICO Y SOCIAL mantendría la ventaja."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Proyección\n",
"\n",
"Multiplicamos la cantidad de mesas no escrutadas por los votos promedios por mesa de cada partido en cada seccion"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"def por_seccion(prom, sec):\n",
" mesas = 0\n",
" if sec in mesas_pendientes_por_seccion:\n",
" mesas += mesas_pendientes_por_seccion[sec]\n",
" if sec in mesas_desestimadas_por_seccion:\n",
" mesas += mesas_desestimadas_por_seccion[sec]\n",
" return int(prom)*mesas"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {
"collapsed": false,
"scrolled": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"FPV: 558740 Votos\n",
"PRO: 582576 Votos\n",
"FPCYS: 585198 Votos\n",
"Diferencia a favor del Socialismo: 2622\n"
]
}
],
"source": [
"fpcys = 558352\n",
"pro = 556224\n",
"fpv = 532156\n",
"\n",
"for row in votos_promedio_seccion.iterrows():\n",
" if row[0][1] == \"0004\":\n",
" fpv += por_seccion(row[1], row[0][0])\n",
" elif row[0][1] == \"0005\":\n",
" pro += por_seccion(row[1], row[0][0])\n",
" elif row[0][1] == \"0006\":\n",
" fpcys += por_seccion(row[1], row[0][0])\n",
" \n",
"print \"FPV: %d Votos\" % fpv\n",
"print \"PRO: %d Votos\" % pro\n",
"print \"FPCYS: %d Votos\" % fpcys\n",
"\n",
"print \"Diferencia a favor del Socialismo: %d\" % (fpcys - pro)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"####Segun esta proyección gana el socialismo por más de 2600 votos. "
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": true
},
"source": [
"### Colaboradores\n",
"\n",
"[@tin\\_nqn\\_](https://twitter.com/tin_nqn_) Martín Gaitan\n",
"\n",
"[@pdelboca](https://twitter.com/pdelboca) Patricio del Boca\n",
"\n",
"[@jairotrad](https://twitter.com/jairotrad) Jairo Trad\n",
"\n",
"[@frod_f](https://twitter.com/frod_f) Franco Rodriguez\n",
" \n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment