Skip to content

Instantly share code, notes, and snippets.

View wrobstory's full-sized avatar

Rob Story wrobstory

View GitHub Profile
@wrobstory
wrobstory / README.md
Last active April 15, 2020 03:18
Folium Income Choropleth

A Leaflet.js map created with Folium and a custom D3 threshold scale, with data bound between the Pandas DataFrame and the TopoJSON. See the Gist for the python code to generate the dataframe. The map was generated with the following Python code:

map_3 = folium.Map(location=[40, -99], zoom_start=4)
map_3.geo_json(geo_path=county_geo, data_out='data3.json', data=df,
               columns=['GEO_ID', 'Median_Household_Income_2011'],
               key_on='feature.id',
               fill_color='PuRd', line_opacity=0.3,
               legend_name='Median Household Income 2011 ($)',
 topojson='objects.us_counties_20m')
@wrobstory
wrobstory / README.md
Last active February 10, 2020 00:57
Folium Simple Markers

A Leaflet.js map created with Folium. This map was generated with the following Python code:

import folium

map_1 = folium.Map(location=[45.372, -121.6972], zoom_start=12,
                   tiles='Stamen Terrain')
map_1.simple_marker([45.3288, -121.6625], popup='Mt. Hood Meadows')
map_1.simple_marker([45.3311, -121.7113], popup='Timberline Lodge')
map_1.create_map(path='mthood.html')
@wrobstory
wrobstory / gist:06471b5cd9046a6e50e0
Last active December 13, 2019 20:11
Fastest Clojure Sum
;; Gaussian sum!
user=> (crit/with-progress-reporting (crit/quick-bench (/ (* (+ 1 99999) 99999) 2)))
Warming up for JIT optimisations 5000000000 ...
compilation occured before 333366 iterations
Estimating execution count ...
Sampling ...
Final GC...
Checking GC...
WARNING: Final GC required 8.548926352381509 % of runtime
Finding outliers ...
@wrobstory
wrobstory / .gitignore
Last active May 13, 2019 12:19
PyData2014
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
# C extensions
*.so
# Distribution / packaging
.Python
env/
@wrobstory
wrobstory / README.md
Last active April 22, 2019 17:24
Folium Choropleth Default

A Leaflet.js map created with Folium and the default D3 threshold scale. See the Gist for the python code to generate the dataframe. The map was generated with the following Python code:

map = folium.Map(location=[48, -102], zoom_start=3)
map.geo_json(geo_path=state_geo, data=state_data,
             columns=['State', 'Unemployment'],
             key_on='feature.id',
             fill_color='YlGn', fill_opacity=0.7, line_opacity=0.2,
             legend_name='Unemployment Rate (%)')
map.create_map(path='us_states.html')
@wrobstory
wrobstory / README.md
Last active November 4, 2018 14:21
Folium Choropleth

A choropleth map created with Folium and Pandas. Pull data into a dataframe, bind to a feature of the GeoJSON, map it. Folium allows you to specify any of the color brewer sequential color groups, and also allows you to specify the d3 quantize scale range:

import folium
import json
import pandas as pd
import vincent

county_data = r'us_county_data.csv'
county_geo = r'us-counties.json'
@wrobstory
wrobstory / README.md
Last active December 23, 2017 10:41
Folium Circle Markers

A Leaflet.js map created with Folium- click on the marker to see the popup text. This map was generated with the following Python code:

map_2 = folium.Map(location=[45.5236, -122.6750], tiles='Stamen Toner',
                   zoom_start=13)
map_2.simple_marker(location=[45.5244, -122.6699], popup='The Waterfront')
map_2.circle_marker(location=[45.5215, -122.6261], radius=500,
                    popup='Laurelhurst Park', line_color='#3186cc',
                    fill_color='#3186cc')
map_2.create_map(path='portland.html')
@wrobstory
wrobstory / gist:bc7636e3254ca733f2d8
Created March 17, 2015 23:13
Py.test Fixture error
import pytest
def setup_function(function):
foo = 1
function(foo)
def test_thing(thing):
two = thing + 1
assert two == 2
@wrobstory
wrobstory / Legend.ipynb
Last active October 13, 2017 10:20
Seaborn legend
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@wrobstory
wrobstory / coreml.py
Created June 6, 2017 17:11
CoreML Serialization
In [1]: %paste
from sklearn.datasets import load_iris
from sklearn import tree
import coremltools
iris = load_iris()
clf = tree.DecisionTreeClassifier()
clf = clf.fit(iris.data, iris.target)
## -- End pasted text --