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 requests | |
| from bs4 import BeautifulSoup | |
| URL_BASE='http://www.autosrobadoschile.com/agregar-robo/9-automoviles?start=%d' | |
| out = [] | |
| for start in range(20): # first 400 robos | |
| url = URL_BASE %(20*start) | |
| print(url) | |
| page = requests.get(url) |
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(tm);library(wordcloud);library(memoise) | |
| books <<- list("A Mid Summer Night's Dream" = "summer", | |
| "Glamorama" = "Glamorama1") # The list of valid books | |
| getTermMatrix <- memoise(function(book) { # Using "memoise" to automatically cache the results | |
| if (!(book %in% books)) stop("Unknown book") | |
| text <- readLines(sprintf("./%s.txt.gz", book), encoding="UTF-8") | |
| myCorpus = Corpus(VectorSource(text)) |
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 requests, sqlite3, pandas as pd | |
| url='https://api.citybik.es/v2/networks/velib' | |
| r=requests.get(url) | |
| conn = sqlite3.connect('pybikes.db') | |
| df = pd.DataFrame(r.json()['network']['stations']) | |
| df = df[['id','name','free_bikes','empty_slots','timestamp']] | |
| df.to_sql('velib', conn,if_exists='append') |
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 json | |
| import pandas as pd | |
| import urllib.request | |
| ori='75+9th+Ave+New+York,+NY' | |
| des='MetLife+Stadium+1+MetLife+Stadium+Dr+East+Rutherford,+NJ+07073' | |
| dep=int(datetime.datetime.now().timestamp()) | |
| URL='https://maps.googleapis.com/maps/api/directions/json?origin=%s&destination=%s&departure_time=%d' %(ori,des,dep) | |
| URL+='&traffic_model=best_guess&key=AIzaSyB_ZS04dfON0PZVBRwhKTkeChK3rlYUgSk' |
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
| # plotly polar: https://plot.ly/python/polar-chart/ | |
| # polar bokeh : https://gist.github.com/jjhelmus/10610995 | |
| # R radar discussion: https://github.com/ropensci/plotly/issues/890 | |
| # and again: https://moderndata.plot.ly/radar-charts-in-r-using-plotly/ | |
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
| # from http://docs.sherlockml.com/libraries/lens/getting_started.html | |
| import lens | |
| import pandas as pd | |
| df=pd.read_csv('300_casas_renam.csv.gz', compression='gzip') | |
| df=df[['id_x','text_x','hext_x','time','tint_y','hint_y','Co2_y','Ruido_y']] | |
| df=df.rename(columns={'id_x':'casa','text_x':'TempExt','hext_x':'HumedadExt', | |
| 'hint_y':'HumedadInt','Co2_y':'CO2', | |
| 'Ruido_y':'Ruido','tint_y':'TempInt'}) |
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
| from dask.distributed import Client | |
| # stands are a list of 50-100 objects with associated methods | |
| def crunched(stand): | |
| stand.compute_stand_volume() # aqui esta el costo del BN1 | |
| return stand | |
| client = Client() | |
| y = [client.submit(crunched, stand) for stand in stands] | |
| self.stands = client.gather(y) # collect the results |
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 sqlite3 | |
| import pandas as pd | |
| db = sqlite3.connect('database.db') | |
| tables = pd.read_sql_query("SELECT * FROM sqlite_master WHERE type='table'", db) | |
| print(tables) |
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 folium | |
| f = folium.Map(location=[-33.413, -70.6], zoom_start=15) | |
| puntos = [(-33.41138735,-70.60239197), | |
| (-33.41411257,-70.60185419), | |
| (-33.41389096,-70.59258862)] | |
| for punto in puntos: | |
| folium.Marker(punto).add_to(f) |
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
| from pytz import timezone | |
| from datetime import datetime | |
| def localtime(): | |
| santiago = timezone('America/Santiago') | |
| scl_time = datetime.now(santiago) | |
| return scl_time.strftime('%Y-%m-%d_%H-%M-%S') |