import matplotlib.pyplot as plt import matplotlib.animation as animation import matplotlib.cm as cm from mpl_toolkits.basemap import Basemap from matplotlib.patches import Polygon from matplotlib.collections import PatchCollection from matplotlib.colors import Normalize import neighborhoodize print "where" hood_map = neighborhoodize.NeighborhoodMap(neighborhoodize.zillow.ILLINOIS) fig = plt.figure() ax = fig.add_subplot(1, 1, 1) print "where" mymap = Basemap(llcrnrlon=-87.9, llcrnrlat=41.3, urcrnrlon=-86.91, urcrnrlat=42.7, projection='lcc', lat_1=32, lat_2=45, lon_0=-95, resolution='h') print "where" mymap.drawmapboundary(fill_color='#46bcec') mymap.fillcontinents(color='#f2f2f2', lake_color='#46bcec') mymap.drawcoastlines() print "where" for hood in hood_map.neighborhoods: print hood.name
def test_nyc_zillow(): params = neighborhoodize.zillow.NEW_YORK nyc_map = neighborhoodize.NeighborhoodMap(params) for (lat, lng), answer in known_zillow_nyc_pairs.iteritems(): assert nyc_map.get_neighborhoods(lat, lng) == answer
def test_chicago_zillow(): params = neighborhoodize.zillow.ILLINOIS chicago_map = neighborhoodize.NeighborhoodMap(params) for (lat, lng), answer in known_chicago_pairs.iteritems(): assert chicago_map.get_neighborhoods(lat, lng) == answer
def test_nyc_city(): params = neighborhoodize.nyc.NEIGHBORHOOD_TABULATION_AREAS nyc_map = neighborhoodize.NeighborhoodMap(params) for (lat, lng), answer in known_city_nyc_pairs.iteritems(): assert nyc_map.get_neighborhoods(lat, lng) == answer
def test_chicago_city(): params = neighborhoodize.city_of_chicago.NEIGHBORHOODS chicago_map = neighborhoodize.NeighborhoodMap(params) for (lat, lng), answer in known_chicago_pairs.iteritems(): assert chicago_map.get_neighborhoods(lat, lng) == answer
# coding: utf-8 # In[1]: import pandas as pd import numpy as np import zipfile import requests import StringIO import os from datetime import datetime import neighborhoodize hood_map = neighborhoodize.NeighborhoodMap(neighborhoodize.zillow.NEW_YORK) def get_neighbor(df): neighbor_list = [] for i in range(df.shape[0]): neighbor = hood_map.get_neighborhoods(df['Lat'][i], df['Lon'][i]) neighbor_list.append(neighbor) neighbors = pd.DataFrame(neighbor_list) return neighbors def get_time_piece(df): date_time = pd.DataFrame( df['Date/Time'].map(lambda x: x.split(' ')).tolist(),