income and FHV trips per region 20190213-2048




Pay Notebook Creator: Ning Wei0
Set Container: Numerical CPU with TINY Memory for 10 Minutes 0
Total0

Income by neighborhood

In [2]:
# CrossCompute
target_folder = '/tmp'
In [3]:
import geotable
url2 = "https://www1.nyc.gov/assets/planning/download/zip/data-maps/open-data/nynta_18d.zip"
nta = geotable.load(url2)
In [4]:
#nta.draw()
In [5]:
nta.iloc[0]
Out[5]:
BoroCode                                                           3
BoroName                                                    Brooklyn
CountyFIPS                                                       047
NTACode                                                         BK88
NTAName                                                 Borough Park
Shape_Leng                                                   39247.2
Shape_Area                                                5.4005e+07
geometry_object    POLYGON ((990897.9000244141 169268.1207885742,...
geometry_layer                                                 nynta
geometry_proj4     +proj=lcc +lat_1=40.66666666666666 +lat_2=41.0...
Name: 0, dtype: object
In [6]:
#Import ACS dataset on median income by NTA
import pandas as pd
acs = pd.read_excel("https://www1.nyc.gov/assets/planning/download/office/data-maps/nyc-population/acs/econ_2016acs5yr_nta.xlsx?r=1")
In [7]:
acs = acs.set_index("GeoID")
In [8]:
incomes = acs['MdFamIncE']
In [9]:
nta = nta.set_index('NTACode')
In [10]:
nta['Median Income'] = incomes
In [11]:
nta[:3]
Out[11]:
<style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; } .dataframe tbody tr th { vertical-align: top; } .dataframe thead th { text-align: right; } </style>
BoroCode BoroName CountyFIPS NTAName Shape_Leng Shape_Area geometry_object geometry_layer geometry_proj4 Median Income
NTACode
BK88 3 Brooklyn 047 Borough Park 39247.228028 5.400502e+07 POLYGON ((990897.9000244141 169268.1207885742,... nynta +proj=lcc +lat_1=40.66666666666666 +lat_2=41.0... 38187.0
QN51 4 Queens 081 Murray Hill 33266.904861 5.248828e+07 POLYGON ((1038593.459228516 221913.3550415039,... nynta +proj=lcc +lat_1=40.66666666666666 +lat_2=41.0... 59007.0
QN27 4 Queens 081 East Elmhurst 19816.712318 1.972685e+07 POLYGON ((1022728.275024414 217530.8082275391,... nynta +proj=lcc +lat_1=40.66666666666666 +lat_2=41.0... 56157.0
In [12]:
Map_geotable = nta.copy()
In [13]:
Map_geotable['fill_greens'] = Map_geotable['Median Income']
In [14]:
target_path = target_folder + '/choropleth.csv'
Map_geotable.to_csv(target_path, index=False)
print('a_geotable_path = %s' % target_path)
a_geotable_path = /tmp/choropleth.csv
In [15]:
Map_geotable.draw()
Out[15]:
<geotable.ColorfulGeometryCollection at 0x7f3cb927be10>
In [ ]: