This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
year | index | rate | |
---|---|---|---|
2013 | 1 | 0.29263404 | |
2013 | 2 | 0.268499255 | |
2013 | 3 | 0.359004647 | |
2013 | 4 | 0.371072024 | |
2013 | 5 | 0.352970958 | |
2013 | 6 | 0.235313967 | |
2013 | 7 | 0.247381344 | |
2013 | 8 | 0.307718247 | |
2013 | 9 | 0.349954098 |
We can make this file beautiful and searchable if this error is corrected: It looks like row 9 should actually have 21 columns, instead of 18 in line 8.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"Injury Severity","Person Position", "Total","1999","2000","2001","2002","2003","2004","2005","2006","2007","2008","2009","2010","2011","2012","2013","2014","2015","2016" | |
"Total","Total",44167,2980,2904,2758,2921,2777,2735,2898,2871,2753,2431,2216,2238,2023,2075,1951,1846,1895,1895 | |
"Total","Driver/Operator",26745,1760,1685,1669,1750,1650,1644,1787,1800,1660,1525,1378,1350,1240,1239,1188,1129,1154,1137 | |
"Total","Front row, center",598,58,43,45,54,49,34,52,23,34,32,28,34,26,22,16,19,19,10 | |
"Total","Front row, right outboard, including motorcycle passenger in sidecar",5862,440,465,391,446,404,390,421,380,355,298,267,295,245,259,193,221,186,206 | |
"Total","Second row, left outboard, including motorcycle passenger",1344,93,108,87,85,104,84,77,94,90,72,51,68,49,54,52,55,68,53 | |
"Total","Second row, center",501,42,37,36,33,35,35,25,23,37,30,23,20,27,35,23,9,16,15 | |
"Total","Second row, right outboard",1293,97,90,85,94,81,92,97,87,84,57,66,74,49,60,50,42,47,41 | |
"Total","Third row, left outboard",35,0,1,2,2,3,3,1,1,4,0,1,2,0,1, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
side = '\({[<' | |
other_side = '/)}]>' | |
centered = '"*:|oOwWvVXx!^+=-08TYUuMA' | |
transformer = dict(list(zip(side, other_side)) + list(zip(other_side, side)) + list(zip(centered, centered))) | |
total = list(side + other_side + centered) | |
def row(centered_flower, size): | |
result = '' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
columnas = ['partido cambio radical', | |
'partido polo democrático alternativo', | |
'partido social de unidad nacional partido de la u', | |
'partido liberal colombiano', | |
'partido alianza verde', | |
'partido conservador colombiano', | |
'partido centro democrático', | |
'coalición lista de la decencia (asi,up,mais)'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import seaborn as sns | |
sns.set(style='ticks', color_codes=True) | |
sns.set_palette(sns.color_palette('RdGy', 10)[::-1]) | |
senado = pd.read_csv('datos/senado.csv.gz') | |
participacion = pd.read_csv('datos/participacion.csv') | |
partidos =['coalición lista de la decencia (asi,up,mais)', | |
'partido alianza verde', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
municipio departamento farc el patriota | |
0 Abejorral Antioquia 4 0 | |
1 Abriaqui Antioquia 0 1 | |
2 Alejandria Antioquia 1 1 | |
3 Amaga Antioquia 7 2 | |
4 Amalfi Antioquia 5 0 | |
5 Andes Antioquia 13 10 | |
6 Angelopolis Antioquia 1 0 | |
7 Angostura Antioquia 18 0 | |
8 Anori Antioquia 107 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
el patriota voto en blanco | |
municipio | |
Abejorral 0 88 | |
Abriaqui 1 10 | |
Alejandria 1 42 | |
Amaga 2 314 | |
Amalfi 0 156 | |
Andes 10 361 | |
Angelopolis 0 51 | |
Angostura 0 57 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
candidato_nombre Gustavo Petro Iván Duque diferencia | |
departamento municipio | |
Amazonas El Encanto 12.0 9.0 3.0 | |
La Chorrera 302.0 15.0 287.0 | |
La Pedrera 29.0 9.0 20.0 | |
La Victoria 13.0 1.0 12.0 | |
Miriti Parana 29.0 3.0 26.0 | |
Puerto Arica 16.0 5.0 11.0 | |
Puerto Nariño 290.0 123.0 167.0 | |
Puerto Santander 23.0 10.0 13.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(dplyr) | |
explode <- function(df, f) { | |
df_indexed <- df %>% mutate (explosion_index=1:n()) | |
f_indexed <- function(row_indexed) { | |
return(f(row_indexed) %>% mutate(explosion_index=row_indexed['explosion_index'])) | |
} | |
expansion <- df_indexed %>% apply(1, f_indexed) %>% do.call(rbind, .) | |
explosion <- df_indexed %>% | |
left_join(expansion, by='explosion_index') %>% |