Skip to content

Instantly share code, notes, and snippets.

View aniversarioperu's full-sized avatar

AniversarioPeru aniversarioperu

View GitHub Profile
@aniversarioperu
aniversarioperu / plotear_tuits.py
Created December 25, 2013 14:15
Código para plotear tuits conteniendo la palabra INCENDIO. Ver post en http://aniversarioperu.utero.pe/2013/12/25/feliz-navidad-con-incendio-para-todos/
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import codecs
import re
import datetime
import time
from itertools import groupby
import numpy as np
import matplotlib.pyplot as plt
@aniversarioperu
aniversarioperu / tuits_incendio.csv
Last active January 1, 2016 09:09
tuits de la cuenta @bomberos conteniendo la palabra INCENDIO durante el mes de Diciembre 2013. Ver post en http://aniversarioperu.utero.pe/2013/12/25/feliz-navidad-con-incendio-para-todos/
We can make this file beautiful and searchable if this error is corrected: It looks like row 9 should actually have 4 columns, instead of 3. in line 8.
415727619427299328,2013-12-25 06:16:02 +0000,bomberos,INCENDIO Carreteras - Panamericanas Panamericana Sur 16.4 San Juan De Miraflores M120-3
415727115305504768,2013-12-25 06:14:02 +0000,bomberos,INCENDIO Cl. Cucarda 200 CIST176-4
415726862464483328,2013-12-25 06:13:02 +0000,bomberos,INCENDIO Av. Villa Hermosa (huascar) (coronel Francisco Bolognesi) (4) 000 San Juan De Lurigancho M65-1
415724752737955840,2013-12-25 06:04:39 +0000,bomberos,"RT @televivape: ""@bomberos: INCENDIO Pj. Pamplona Alta Sector Ollantay Mz U3 Lt 5 San Juan De Miraflores M138-4"""
415724096505516032,2013-12-25 06:02:03 +0000,bomberos,INCENDIO Cl. Emilio Fernandez 693 Lima M4-5
415723088089976832,2013-12-25 05:58:02 +0000,bomberos,INCENDIO Pj. Pamplona Alta Sector Ollantay Mz U3 Lt 5 San Juan De Miraflores M138-4
415722083558367232,2013-12-25 05:54:03 +0000,bomberos,INCENDIO Barrio Chocoy M73-3
415722082702721024,2013-12-25 05:54:02 +0000,bomberos,INCENDIO Jr. Fernandez Quiroz 000 Lima
415720575215370241,2013-12-25 05:48:03 +0000,bombero
@aniversarioperu
aniversarioperu / leeme_votaciones.py
Created December 1, 2013 17:08
Script para ver cómo ha votado Peru, Chile y EEU (PE, CL, US) en las negociaciones del TPP filtrado por Wikileaks (http://wikileaks.org/tpp/)
import re
import sys
f = open(sys.argv[1].strip(), "r")
lines = f.readlines()
f.close()
def clean_line(line):
propose = ""
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import codecs
import re
import datetime
import time
from itertools import groupby
import numpy as np
import matplotlib.pyplot as plt
@aniversarioperu
aniversarioperu / datos.txt
Created November 4, 2013 20:45
número total de delitos Perú, años 2005 al 2012. Fuente INEI
152516
153055
144205
151560
160848
181866
206610
254405
@aniversarioperu
aniversarioperu / delitos_bayesian.py
Created November 3, 2013 18:11
Análisis estadístico bayesiano del número de delitos por año para Perú. Se obtiene el número esperado de delitos y el año más probable en que se produjo un aumento en la cantidad de delitos. Usando teoría y cógidos de "Bayesian methods for hackers": http://bit.ly/19tyAUX
# -*- coding: utf-8 -*-
import prettyplotlib as ppl
from prettyplotlib import plt
import sys
import pymc as pm
import numpy as np
datos = np.loadtxt("datos.txt")
alpha = 1.0/datos.mean()
print alpha
@aniversarioperu
aniversarioperu / lm.R
Created November 3, 2013 18:08
Plot del total de delitos por año para Perú. Datos tomados del INEI: http://www.inei.gob.pe/media/MenuRecursivo/Cap08005.xls
library(ggplot2)
y <- read.csv("datos.txt", header=FALSE)
y <- as.vector(y[,1])
x <- 2005:2012
int <- lsfit(x,y)$coefficients[1]
slope <- lsfit(x,y)$coefficients[2]
p <- ggplot(,aes(x,y))
p + geom_point() + geom_abline(intercept=int, slope=slope) +
labs(title = "Perú: Número total de delitos por año")
@aniversarioperu
aniversarioperu / intoxicados_qali_warma.csv
Created October 27, 2013 09:47
número de intoxicados por Qali Warma por fecha y link a la nota de prensa.
Loreto 2013-10-25 80 http://bit.ly/18YdMbA
Junin 2013-09-28 35 http://bit.ly/18qqNpT
Curahuasi 2013-09-18 50 http://bit.ly/18qqEmx
Huanuco 2013-04-18 17 http://bit.ly/18qqzPL
Urubamba 2013-04-15 100 http://bit.ly/18qqlYX
Ucayali 2013-10-05 15 http://bit.ly/18qqfAm
Satipo 2013-09-27 24 http://bit.ly/18YeiGx
@aniversarioperu
aniversarioperu / tabla4.csv
Created October 22, 2013 20:55
Tabla 4. Porcentaje de pobres multidimensionales vs. Gasto social por departamento, Perú 2012
Moquegua 24.8 1949
Tumbes 28.4 1839
Ayacucho 56.6 1779
Pasco 55.8 1769
Huancavelica 68.5 1750
Apurímac 60.9 1725
Madre de Dios 27.1 1584
Cusco 38.2 1574
Amazonas 61.7 1404
Tacna 26.5 1399
@aniversarioperu
aniversarioperu / top20.py
Created October 22, 2013 14:05
top20 mas toneras radio inspiracion
# -*- coding: utf-8 -*-
import prettyplotlib as ppl
import numpy as np
from prettyplotlib import plt
import csv
from array import array
""" Top 20 ranking """
x = []