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 | |
| import pandas as pd | |
| import requests | |
| blc = pd.read_json('https://www.bicilascondes.cl/availability_map/getJsonObject') # BiciLasCondes | |
| js = requests.get('https://api.citybik.es/v2/networks/santiago').json() # BikeSantiago | |
| bs = pd.DataFrame(js['network']['stations']).rename(columns={'latitude':'lat','longitude':'lon'}) | |
| def get_mobike(lat,lon): |
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
| { | |
| "nodes": [ | |
| {"id": "J_Pizarro", "group": 1}, | |
| {"id": "P_Walker", "group": 1}, | |
| {"id": "B_Prokurica", "group": 8}, | |
| {"id": "J_Ossandón", "group": 8}, | |
| {"id": "R_Lagos", "group": 5}, | |
| {"id": "J_García", "group": 8}, | |
| {"id": "C_Bianchi", "group": 7}, | |
| {"id": "A_Zaldívar", "group": 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 folium, pandas as pd | |
| blc = pd.read_json('https://www.bicilascondes.cl/availability_map/getJsonObject') | |
| blc = blc.drop(['address','addressNumber','district','zip'], axis=1) | |
| m = folium.Map(location=[blc.lat.mean(),blc.lon.mean()], zoom_start=14) | |
| bikes = lambda row: 'red' if row['bikes']==0 else 'purple' if row['bikes']<5 else 'green' | |
| for id, station_data in blc.iterrows(): | |
| folium.Marker((station_data['lat'],station_data['lon']), | |
| icon=folium.Icon(color=bikes(station_data), icon='bicycle'), | |
| popup=station_data.to_frame().to_html(header=False,justify='center')).add_to(m) | |
| m.save('bicis.html') |
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 geopandas | |
| import pandas as pd | |
| from shapely.geometry import Point | |
| gdf = gp.read_file('http://quant.cl/static/DATA/GEO/comunas13.json') | |
| rand = pd.np.random.randn | |
| points=[Point((-70.7+0.1*rand(),-33.4+0.1*rand())) for _ in range(10)] | |
| for point in points: | |
| for cid,comuna in gdf.iterrows(): |
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
| # for every city, we fetch and plot data from all available parameters | |
| import openaq | |
| import matplotlib.pyplot as plt | |
| import seaborn as sns | |
| sns.set(style="white", palette='muted', font_scale=1.35, color_codes=True) | |
| api = openaq.OpenAQ() | |
| def get_city_data(city='Santiago'): | |
| df = api.measurements(city=city, limit=10000, df=True) | |
| df = df.query("value >= 0.0") # clean up the data by removing values below 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
| import requests, sys | |
| from bs4 import BeautifulSoup | |
| from docx import Document | |
| ubs = lambda url:BeautifulSoup(requests.get(url).text,'html5lib') | |
| def get_chords(artist = 'Manu Chao'): | |
| fartist = '_'.join(s.lower() for s in artist.split()) # use map | |
| url = f'https://acordes.lacuerda.net/{fartist}/' |
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 | |
| from operator import methodcaller | |
| url_bs = lambda url: BeautifulSoup(requests.get(url).text,'html5lib') # magic! | |
| def recopila_acordes(artista = 'Manu Chao'): # "Manu Chao" -> manu_chao | |
| fartist = '_'.join(map(methodcaller("lower"),artista.split())) | |
| url = f'https://acordes.lacuerda.net/{fartist}/' | |
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 docx import Document | |
| def compilar_cancionero(artista): | |
| data_canciones = recopila_acordes(artista) | |
| document = Document() | |
| document.add_heading(artista, 0) | |
| for songname, song_chords in data_canciones.items(): |
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 folium, requests, time | |
| fm=folium.Map([-33.4,-70.65], zoom_start=12) | |
| #LINEAS = ['101','206', '345'] | |
| recorridos = eval(requests.get('http://www.transantiago.cl/restservice/rest/getservicios/all').text) | |
| LINEAS = recorridos #[:10] |
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 | |
| import pandas as pd | |
| from bs4 import BeautifulSoup | |
| # IDEAS: multas, elencos: http://es.teleserieschile.wikia.com/wiki/Categor%C3%ADa:Teleseries_de_Canal_13 | |
| bs=BeautifulSoup(requests.get('https://www.cntv.cl/cntv/site/tax/port/all/taxport_16___1.html').text,'html5') | |
| links = bs.find_all('a') | |
| denuncias=[l for l in links if 'Lo más' in l.text] | |
| droot='https://www.cntv.cl' | |
| df=pd.DataFrame() |