Skip to content

Instantly share code, notes, and snippets.

View fmasanori's full-sized avatar

Fernando Masanori fmasanori

View GitHub Profile
@fmasanori
fmasanori / get_covid_data_jhu.py
Created June 8, 2020 14:25 — forked from jvfe/get_covid_data_jhu.py
Function to create COVID-19 dataset from JHU github
import pandas as pd
import datetime
def get_covid_data_jhu(dt_ini, dt_fim, us_columns = True, country = None):
date_range = pd.date_range(start = dt_ini, end = dt_fim).to_list()
string_range = [str(d.date().strftime("%m-%d-%Y")) for d in date_range]
full_data_list = []
for dat in string_range:
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@fmasanori
fmasanori / Dinheiro_conversão.ipynb
Created May 29, 2019 12:48
Conversão Monetária
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@fmasanori
fmasanori / escolas.py
Created February 26, 2019 18:48
Escolas em funcionamento, sem luz, água e esgoto
import requests
url = 'http://educacao.dadosabertosbr.com/api/escolas/buscaavancada?'
situação = 'situacaoFuncionamento=1&energiaInexistente=on&aguaInexistente=on&esgotoInexistente=on'
data = requests.get(url + situação).json()
print ('Primeiras 100 escolas:')
for escola in data[1]:
print (f'{escola["nome"]}, {escola["cidade"]}, {escola["estado"]}')
print ('Escolas em funcionamento, sem água, luz e esgoto:')
print (data[0])
@fmasanori
fmasanori / booyermoore.py
Last active September 14, 2018 12:36
BooyerMoore
def boyermoore(p, t):
m = len(p)
n = len(t)
if m > n: return -1
pulo = [m for k in range(256)]
for k in range(m - 1):
pulo[ord(p[k])] = m - k - 1
pulo = tuple(pulo)
k = m - 1
while k < n:
import ast
import codegen
expr='''
def resposta():
print ('Alô Mundo')
'''
p = ast.parse(expr)
p.body[0].body = [ast.parse('return 42').body[0]]
@fmasanori
fmasanori / bnmp_scraping_detail.py
Created April 27, 2018 14:10
BNMP Scraping Detail (by Felipe Koblinger)
import pymongo
import requests
headers = {
'Host': 'www.cnj.jus.br',
'Connection': 'keep-alive',
'Accept': 'application/json, text/plain, */*',
'Origin': 'http://www.cnj.jus.br',
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36',
'Content-Type': 'application/json;charset=UTF-8',
@fmasanori
fmasanori / bnmp_scraping_court_orders.py
Created April 27, 2018 14:08
BNMP Scraping Court Orders (by Felipe Koblinger)
import pymongo
import requests
from redis import Redis
from rq import Queue
from bnmp_scraping_detail import download_court_order_detail
headers = {
'Host': 'www.cnj.jus.br',
'Connection': 'keep-alive',
'Accept': 'application/json, text/plain, */*',
@fmasanori
fmasanori / bnmp_scraping.py
Created April 27, 2018 14:06
BNMP scraping (by Felipe Koblinger)
import requests
import json
import time
import threading
from redis import Redis
from rq import Queue
from bnmp_scraping_court_orders import download_state_page
headers = {
'Host': 'www.cnj.jus.br',
@fmasanori
fmasanori / ER_para_limpar_dados.py
Created March 12, 2018 13:37
Limpeza de Dados com ER
import re
p = re.compile(r'\d+')
d, m, a = p.findall('09-03-2018')
print (d, m, a)
d, m, a = p.findall('09/03/2018')
print (d, m, a)
a, m, d = p.findall('6(anos) 2(meses) 10(dias)')
print(a, m, d)
a, m, d = p.findall('6a2m10d')