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 csv | |
| from pyxlsb import open_workbook | |
| with open_workbook('PUB_Reg_Com_Rub_Sub_Act.xlsb') as wb: | |
| for sheetname in wb.sheets: | |
| print(sheetname) | |
| ofile = open(sheetname.split('_')[0]+'.csv', "w") | |
| writer = csv.writer(ofile, delimiter=',', | |
| quotechar='"', quoting=csv.QUOTE_ALL) | |
| with wb.get_sheet(sheetname) as sheet: |
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 matplotlib.pyplot as plt | |
| import squarify # pip install squarify (algorithm for treemap) | |
| from datachile import ChileCube | |
| client = ChileCube() | |
| query = client.get("exports", | |
| {"drilldowns": [ | |
| ["Date", "Year"], | |
| ["Destination Country", "Country", "Country"] |
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 time | |
| from bs4 import BeautifulSoup | |
| from selenium import webdriver | |
| base_url='https://www.mercantil.com/restaurantes/1502/' | |
| driver = webdriver.Firefox() | |
| driver.get(base_url) | |
| for item in range(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
| from tpot import TPOTRegressor | |
| from sklearn.datasets import load_boston | |
| from sklearn.model_selection import train_test_split | |
| housing = load_boston() | |
| X_train, X_test, y_train, y_test = train_test_split(housing.data, housing.target, | |
| train_size=0.75, test_size=0.25) | |
| tpot = TPOTRegressor(generations=5, population_size=50, verbosity=2) | |
| tpot.fit(X_train, y_train) |
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, requests | |
| import pandas as pd | |
| url = 'https://api.foursquare.com/v2/venues/explore' | |
| CLIENT_ID = 'ES4CLZNVL5AX3E43RY1115LHJGZ2HIULJWLFMZFVH03MPHHO' | |
| CLIENT_SECRET = 'OZZKEKTKH2BAIW3BNG3ZSM5MUOH444XJHQKQIZDDPFMDMBXN' | |
| params = dict( | |
| client_id=CLIENT_ID, | |
| client_secret=CLIENT_SECRET, |
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 sqlite3 | |
| import requests | |
| import time | |
| base_url = 'http://api.citybik.es' | |
| list_tail = '/v2/networks/?fields=id,name,href' | |
| nets = requests.get(base_url+list_tail).json()['networks'] # retrieves system list | |
| print('FOUND: %d networks' %len(nets)) |
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 pybikes #pip install git+https://github.com/eskerda/pybikes.git | |
| blc = pybikes.get('bicilascondes') # system added to Citybikes by yours truly! | |
| blc.update() | |
| print len(blc.stations) # usually, 89 | |
| print blc.stations[0] | |
| ''' | |
| --- u'001 VITACURA / SAN PATRICIO' --- | |
| bikes: 4 | |
| free: 15 | |
| latlng: -33.41138735,-70.60239197 |
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 | |
| base_url = 'http://api.citybik.es' | |
| list_tail = '/v2/networks/?fields=id,name,href' | |
| nets = requests.get(base_url+list_tail).json()['networks'] # retrieves system list | |
| print('FOUND: %d networks' %len(nets)) # 561 last I checked on 20180423 | |
| print(nets[0]) | |
| # {'href': '/v2/networks/bbbike', 'id': 'bbbike', 'name': 'BBBike'} |
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
| #git clone https://github.com/sanderjo/disk-speed.git | |
| #idea! flask services should be gitable | |
| urls = from git import my_dict | |
| app = [(url,view) for url,view in my_dict] |
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
| Instrucciones para selenium+gecko+firefox | |
| sudo apt-get update | |
| sudo apt-get install python # instalar python | |
| sudo apt-get install python-pip # instalar pip | |
| pip install selenium # instalar selenium | |
| pip install pyvirtualdisplay # instalar pyvirtualdisplay | |
| wget https://github.com/mozilla/geckodriver/releases/download/v0.20.1/geckodriver-v0.20.1-linux64.tar.gz | |
| tar -xvzf geckodriver* # extraer geckodriver |