Using Requests and Beautiful Soup, with the most recent Beautiful Soup 4 docs.
Install our tools (preferably in a new virtualenv):
pip install beautifulsoup4
| import matplotlib.pyplot as plt | |
| from matplotlib.collections import PatchCollection | |
| from descartes import PolygonPatch | |
| import fiona | |
| from shapely.geometry import Polygon, MultiPolygon, shape | |
| # We can extract the London Borough boundaries by filtering on the AREA_CODE key | |
| mp = MultiPolygon( | |
| [shape(pol['geometry']) for pol in fiona.open('data/boroughs/boroughs.shp') | |
| if pol['properties']['AREA_CODE'] == 'LBO']) |
| """ | |
| required packages: | |
| numpy | |
| matplotlib | |
| basemap: http://matplotlib.org/basemap/users/installing.html | |
| shapely: https://pypi.python.org/pypi/Shapely | |
| descartes: https://pypi.python.org/pypi/descartes | |
| random |
| # Two Matching Methods | |
| # Method 1 - GenMatch() | |
| library(Matching) | |
| covars <- c("sick", "age", "literate", "employment", "public", "urban", "poverty", "owndwell") | |
| X <- as.matrix(collapsed.data[,covars]) | |
| W <- collapsed.data$treated_any | |
| g.weights <- GenMatch(Tr=W, X=X, BalanceMatrix=X, estimand="ATT", M=1,print.level=0,max.generations=1,hard.generation.limit=TRUE) | |
| g.weights$matches |
Using Requests and Beautiful Soup, with the most recent Beautiful Soup 4 docs.
Install our tools (preferably in a new virtualenv):
pip install beautifulsoup4