Opening your session in 90 seconds...
Please note that we are starting a new machine for you, which takes more time.
If your browser keeps redirecting back and forth from this page in an endless loop, it is possible that you are using an older browser. Please update Google Chrome or use Mozilla Firefox.
#CrossCompute
# import the data from the district maps dataset
# import demographics data
# append the diversity index to the district maps dataset
# create a cloropleth
target_folder = '/tmp'
url = 'https://data.cityofnewyork.us/api/geospatial/r8nu-ymqj?method=export&format=Shapefile'
import geotable
dist_table = geotable.load(url)
#t.draw()
dist_table[:3]
school_dis | shape_area | shape_leng | geometry_object | geometry_layer | geometry_proj4 | |
---|---|---|---|---|---|---|
0 | 16.0 | 4.676362e+07 | 35848.904605 | POLYGON ((-73.93311862859143 40.69579115384632... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs |
1 | 32.0 | 5.189850e+07 | 37251.057847 | POLYGON ((-73.91180710069435 40.70343495202662... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs |
2 | 6.0 | 9.634170e+07 | 70447.849084 | POLYGON ((-73.92640556921116 40.87762147653734... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs |
dist_table.iloc[0]
school_dis 16 shape_area 4.67636e+07 shape_leng 35848.9 geometry_object POLYGON ((-73.93311862859143 40.69579115384632... geometry_layer geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 geometry_proj4 +proj=longlat +ellps=WGS84 +no_defs Name: 0, dtype: object
url = 'https://data.cityofnewyork.us/resource/98et-3mve.csv'
import pandas as pd
def load(
endpoint_url,
selected_columns=None,
buffer_size=1000,
search_term_by_column=None,
**kw,
):
buffer_url = (f'{endpoint_url}?$limit={buffer_size}')
if selected_columns:
select_string = ','.join(selected_columns)
buffer_url += f'&$select={select_string}'
for column, search_term in (search_term_by_column or {}).items():
buffer_url += f'&$where={column}+like+"%25{search_term}%25"'
print(buffer_url)
tables = []
if endpoint_url.endswith('.json'):
f = pd.read_json
else:
f = pd.read_csv
t = f(buffer_url, **kw)
while len(t):
print(len(tables) * buffer_size + len(t))
tables.append(t)
offset = buffer_size * len(tables)
t = f(buffer_url + f'&$offset={offset}', **kw)
return pd.concat(tables, ignore_index=True, sort=False)
demo_table = load(url, na_values=['No Data'])
https://data.cityofnewyork.us/resource/98et-3mve.csv?$limit=1000 1000 2000 3000 4000 5000 6000 7000 8000 8972
# len(demo_table)
# demo_table.iloc[0]
# demo_table = pd.read_csv(url, na_values=['No Data'])
demo_table.iloc[0]
asian_1 9 asian_2 4.7 black_1 72 black_2 37.9 dbn 01M015 economic_need_index NaN english_language_learners_1 19 english_language_learners_2 10 female_1 93 female_2 48.9 grade_1 39 grade_10 0 grade_11 0 grade_12 0 grade_2 21 grade_3 16 grade_4 26 grade_5 23 grade_6 0 grade_7 0 grade_8 0 grade_9 0 grade_k 39 grade_pk_half_day_full_day 26 hispanic_1 104 hispanic_2 54.7 male_1 97 male_2 51.1 multiple_race_categories_not_represented_1 2 multiple_race_categories_not_represented_2 1.1 poverty_1 171 poverty_2 90 school_name P.S. 015 Roberto Clemente students_with_disabilities_1 65 students_with_disabilities_2 34.2 total_enrollment 190 white_1 3 white_2 1.6 year 2013-14 Name: 0, dtype: object
len(demo_table)
8972
demo_table = demo_table.dropna(subset=['economic_need_index'])
len(demo_table)
7242
demo_table.dtypes
asian_1 int64 asian_2 float64 black_1 int64 black_2 float64 dbn object economic_need_index object english_language_learners_1 int64 english_language_learners_2 float64 female_1 int64 female_2 float64 grade_1 int64 grade_10 int64 grade_11 int64 grade_12 int64 grade_2 int64 grade_3 int64 grade_4 int64 grade_5 int64 grade_6 int64 grade_7 int64 grade_8 int64 grade_9 int64 grade_k int64 grade_pk_half_day_full_day int64 hispanic_1 int64 hispanic_2 float64 male_1 int64 male_2 float64 multiple_race_categories_not_represented_1 int64 multiple_race_categories_not_represented_2 float64 poverty_1 int64 poverty_2 float64 school_name object students_with_disabilities_1 int64 students_with_disabilities_2 float64 total_enrollment int64 white_1 int64 white_2 float64 year object dtype: object
demo_table['economic_need_index'] = demo_table['economic_need_index'].str.replace('%', '')
demo_table['economic_need_index'] = demo_table['economic_need_index'].astype('float')
# demo_table.economic_need_index.unique()
len(demo_table)
7242
# # CALCULATE DIVERSITY INDEX OF EACH SCHOOL & ADD TO DEMODF DATAFRAME
# # demo_table['Diversity Index'] = 1
# def d_index(row):
# o = row['% Multiple Race Categories Not Represented']
# total = 100 - o
# target = total / 4
# abs_distance = (abs(target - row['% Asian'])) + abs((target - row['% Black'])) + abs((target - row['% Hispanic'])) + abs((target - row['% White']))
# if o == 0.0:
# return abs_distance
# if o > 0.0:
# # diversity index
# return abs_distance * (1/o)
# # append diversity index to demodf
# # demo_table['Diversity Index'] = demo_table.apply(d_index, axis=1)
# demo_table['Diversity Index'] = demo_table['economic_need_index']
demo_table['Diversity Index'] = demo_table['economic_need_index']
endpoint_url = 'https://data.cityofnewyork.us/resource/r2nx-nhxe.csv'
# Load schools
school_location_table = load(
endpoint_url,
buffer_size=1000)
school_location_table[:5]
https://data.cityofnewyork.us/resource/r2nx-nhxe.csv?$limit=1000 1000 1823
:@computed_region_92fq_4b7q | :@computed_region_efsh_h5xi | :@computed_region_f5dn_yrer | :@computed_region_sbqj_enih | :@computed_region_yeji_bk3q | admin_district_location_code | administrative_district_name | ats_system_code | beds_number | borough_block_lot | ... | primary_building_code | principal_name | principal_phone_number | principal_title | school_support_team_leader_name | school_support_team_name | state_code | status_descriptions | x_coordinate | y_coordinate | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 50.0 | 11729.0 | 70.0 | 5.0 | 4.0 | M801 | COMMUNITY SCHOOL DISTRICT 01 | 01M015 | 310100010015 | 1003740020 | ... | M015 | IRENE SANCHEZ | 212-228-8730 | PRINCIPAL | NaN | School Support Team 3- Manhattan | NY | Open | 990141.0 | 202349.0 |
1 | 50.0 | 11724.0 | 70.0 | 5.0 | 4.0 | M801 | COMMUNITY SCHOOL DISTRICT 01 | 01M019 | 310100010019 | 1004530034 | ... | M019 | JACQUELINE FLANAGAN | 212-533-5340 | PRINCIPAL | NaN | School Support Team 3- Manhattan | NY | Open | 988547.0 | 205239.0 |
2 | 32.0 | 11723.0 | 70.0 | 4.0 | 4.0 | M801 | COMMUNITY SCHOOL DISTRICT 01 | 01M020 | 310100010020 | 1003550001 | ... | M020 | SARAH PINTO VIAGRAN | 212-254-9577 | PRINCIPAL | NaN | School Support Team 3- Manhattan | NY | Open | 988044.0 | 202068.0 |
3 | 50.0 | 11729.0 | 70.0 | 5.0 | 4.0 | M801 | COMMUNITY SCHOOL DISTRICT 01 | 01M034 | 310100010034 | 1003810038 | ... | M034 | ANGELIKI LOUKATOS | 212-228-4433 | PRINCIPAL | NaN | School Support Team 3- Manhattan | NY | Open | 991163.0 | 203782.0 |
4 | 50.0 | 11729.0 | 70.0 | 5.0 | 4.0 | M801 | COMMUNITY SCHOOL DISTRICT 01 | 01M063 | 310100010063 | 1004310014 | ... | M063 | DARLENE CAMERON | 212-674-3180 | PRINCIPAL | NaN | School Support Team 3- Manhattan | NY | Open | 988071.0 | 203210.0 |
school_location_table.iloc[0]
:@computed_region_92fq_4b7q 50 :@computed_region_efsh_h5xi 11729 :@computed_region_f5dn_yrer 70 :@computed_region_sbqj_enih 5 :@computed_region_yeji_bk3q 4 admin_district_location_code M801 administrative_district_name COMMUNITY SCHOOL DISTRICT 01 ats_system_code 01M015 beds_number 310100010015 borough_block_lot 1003740020 census_tract 2601 community_district 103 community_school_sup_name PHILLIPS, DANIELLA council_district 2 fax_number 212-477-0931 field_support_center_leader_name CHU, YUET field_support_center_name Field Support Center - Manhattan fiscal_year 2018 geographical_district_code 1 grades_final_text PK,0K,01,02,03,04,05 grades_text PK,0K,01,02,03,04,05,SE highschool_network_location_code NaN highschool_network_name NaN highschool_network_superintendent NaN location_1 POINT (-73.978747 40.722075) location_1_address 333 EAST 4 STREET location_1_city MANHATTAN location_1_state NY location_1_zip 10009 location_category_description Elementary location_code M015 location_name P.S. 015 Roberto Clemente location_type_description General Academic managed_by_name DOE nta MN28 nta_name Lower East Side ... open_date 1904-07-01T00:00:00.000 primary_address_line_1 333 EAST 4 STREET primary_building_code M015 principal_name IRENE SANCHEZ principal_phone_number 212-228-8730 principal_title PRINCIPAL school_support_team_leader_name NaN school_support_team_name School Support Team 3- Manhattan state_code NY status_descriptions Open x_coordinate 990141 y_coordinate 202349 Name: 0, dtype: object
school_location_table.iloc[0]['location_1']
'POINT (-73.978747 40.722075)'
school_location_table.iloc[0]['ats_system_code']
'01M015 '
school_location_table['DBN'] = school_location_table['ats_system_code'].str.strip()
school_location_table.iloc[0]['DBN']
'01M015'
school_location_table = school_location_table.rename(columns={
'location_1': 'WKT',
'location_name': 'School Name',
})
trimmed_school_location_table = school_location_table[[
'DBN',
'WKT',
'School Name',
]]
school_table = pd.merge(
trimmed_school_location_table,
demo_table,
left_on='DBN',
right_on='dbn')
len(school_table)
7177
school_table = school_table.dropna(subset=['WKT'])
len(school_table)
7173
school_table.iloc[0]
DBN 01M015 WKT POINT (-73.978747 40.722075) School Name P.S. 015 Roberto Clemente asian_1 8 asian_2 4.4 black_1 65 black_2 35.5 dbn 01M015 economic_need_index 93.5 english_language_learners_1 17 english_language_learners_2 9.3 female_1 84 female_2 45.9 grade_1 47 grade_10 0 grade_11 0 grade_12 0 grade_2 31 grade_3 19 grade_4 17 grade_5 24 grade_6 0 grade_7 0 grade_8 0 grade_9 0 grade_k 27 grade_pk_half_day_full_day 18 hispanic_1 107 hispanic_2 58.5 male_1 99 male_2 54.1 multiple_race_categories_not_represented_1 1 multiple_race_categories_not_represented_2 0.5 poverty_1 169 poverty_2 92.3 school_name P.S. 015 Roberto Clemente students_with_disabilities_1 64 students_with_disabilities_2 35 total_enrollment 183 white_1 2 white_2 1.1 year 2014-15 Diversity Index 93.5 Name: 0, dtype: object
dist_table.iloc[0]
school_dis 16 shape_area 4.67636e+07 shape_leng 35848.9 geometry_object POLYGON ((-73.93311862859143 40.69579115384632... geometry_layer geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 geometry_proj4 +proj=longlat +ellps=WGS84 +no_defs Name: 0, dtype: object
geometry_wkt = school_table.iloc[0]['WKT']
geometry_wkt
'POINT (-73.978747 40.722075)'
from shapely import wkt
g = wkt.loads(geometry_wkt)
g
<shapely.geometry.point.Point at 0x7f0dbf48c080>
district_polygons = dist_table['geometry_object']
flags = [x.contains(g) for x in district_polygons]
flags
[False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, False, False, False, False, False, False, False, False, False, False, False, False, False]
import numpy as np
index = np.argmax(flags)
dist_table.iloc[index]
school_dis 1 shape_area 3.51607e+07 shape_leng 28641.3 geometry_object POLYGON ((-73.97177410965313 40.72582128133706... geometry_layer geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 geometry_proj4 +proj=longlat +ellps=WGS84 +no_defs Name: 19, dtype: object
index
19
len(flags)
33
int(dist_table.iloc[index]['school_dis'])
1
len(school_table)
7173
from geotable import ColorfulGeometryCollection, GeoTable
dist_table
school_dis | shape_area | shape_leng | geometry_object | geometry_layer | geometry_proj4 | |
---|---|---|---|---|---|---|
0 | 16.0 | 4.676362e+07 | 35848.904605 | POLYGON ((-73.93311862859143 40.69579115384632... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs |
1 | 32.0 | 5.189850e+07 | 37251.057847 | POLYGON ((-73.91180710069435 40.70343495202662... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs |
2 | 6.0 | 9.634170e+07 | 70447.849084 | POLYGON ((-73.92640556921116 40.87762147653734... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs |
3 | 31.0 | 1.604472e+09 | 434471.412859 | (POLYGON ((-74.05050806403247 40.5664220341608... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs |
4 | 8.0 | 2.588266e+08 | 223080.142631 | (POLYGON ((-73.83979488562171 40.8356192074928... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs |
5 | 7.0 | 9.226247e+07 | 65294.452403 | (POLYGON ((-73.89680883223774 40.7958084451597... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs |
6 | 23.0 | 4.740069e+07 | 40317.452033 | (POLYGON ((-73.92044366203014 40.6656262871675... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs |
7 | 29.0 | 4.201981e+08 | 135035.241651 | POLYGON ((-73.73816144093141 40.72895809117297... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs |
8 | 26.0 | 4.247909e+08 | 125677.678898 | POLYGON ((-73.74344992332192 40.77824115291502... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs |
9 | 15.0 | 1.961534e+08 | 153439.165680 | POLYGON ((-73.98633135042395 40.69105051012824... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs |
10 | 17.0 | 1.284414e+08 | 68341.398899 | POLYGON ((-73.92044366203014 40.6656262871675,... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs |
11 | 19.0 | 2.034175e+08 | 184183.167312 | (POLYGON ((-73.846736514711 40.60485301485166,... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs |
12 | 27.0 | 7.955971e+08 | 589135.502728 | (POLYGON ((-73.82784008953526 40.5887858248046... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs |
13 | 13.0 | 1.048706e+08 | 86635.210559 | POLYGON ((-73.97906084911834 40.70594602894087... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs |
14 | 18.0 | 1.751488e+08 | 121184.158477 | (POLYGON ((-73.86706149472118 40.5820879767934... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs |
15 | 20.0 | 2.426965e+08 | 94309.778946 | POLYGON ((-74.02552971543656 40.65147855069281... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs |
16 | 3.0 | 1.134889e+08 | 52072.051321 | POLYGON ((-73.95671863064405 40.78660079332199... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs |
17 | 5.0 | 5.251977e+07 | 44469.588221 | POLYGON ((-73.93515659239551 40.83268240623763... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs |
18 | 9.0 | 8.341539e+07 | 46648.958586 | POLYGON ((-73.9212971968614 40.85428933985649,... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs |
19 | 1.0 | 3.516075e+07 | 28641.276279 | POLYGON ((-73.97177410965313 40.72582128133706... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs |
20 | 14.0 | 1.503102e+08 | 95792.082090 | POLYGON ((-73.95439555417087 40.73911477252251... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs |
21 | 2.0 | 2.804677e+08 | 214498.703163 | (POLYGON ((-74.0438776163991 40.69018767537123... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs |
22 | 4.0 | 5.262043e+07 | 52061.828459 | (POLYGON ((-73.92133752419399 40.8008521064970... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs |
23 | 10.0 | 2.825415e+08 | 94957.570537 | POLYGON ((-73.86789798628736 40.90294017690526... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs |
24 | 12.0 | 6.907182e+07 | 48527.595776 | POLYGON ((-73.88284445574813 40.84781722645163... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs |
25 | 25.0 | 4.436285e+08 | 175827.007127 | POLYGON ((-73.82049919995312 40.80101146781899... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs |
26 | 28.0 | 2.475679e+08 | 114694.912786 | POLYGON ((-73.84485477879177 40.7357514698091,... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs |
27 | 24.0 | 3.949782e+08 | 127343.703736 | (POLYGON ((-73.90641585511733 40.7398683641967... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs |
28 | 30.0 | 3.181290e+08 | 150392.978241 | POLYGON ((-73.90647314610101 40.79018117520807... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs |
29 | 21.0 | 2.101971e+08 | 123858.087345 | POLYGON ((-73.96184657346174 40.62757081710622... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs |
30 | 22.0 | 3.855533e+08 | 271718.504936 | (POLYGON ((-73.91990064270161 40.5996005215871... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs |
31 | 11.0 | 3.926651e+08 | 305305.863567 | (POLYGON ((-73.78833349834532 40.8346671297593... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs |
32 | 10.0 | 3.282963e+06 | 7883.372664 | (POLYGON ((-73.9089323517538 40.8721573479701,... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs |
dist_table.geometry_object[0].wkt
'POLYGON ((-73.93311862859143 40.69579115384632, -73.93236605675587 40.69535837729649, -73.9319289006206 40.6951146575314, -73.93177404555487 40.69502821484371, -73.93147184545109 40.69486090242515, -73.93121199886629 40.69471276978224, -73.93114516482393 40.69467397486358, -73.930511465969 40.69431652304853, -73.92970192402746 40.69386339761171, -73.92882897891457 40.69335047407161, -73.92882834168937 40.6933500992537, -73.92864268981751 40.69324101255102, -73.92850659671787 40.69316572635911, -73.92804330687132 40.69290417236994, -73.92781120671985 40.6927742086535, -73.92750685270927 40.69260381145623, -73.92707069461525 40.69234622359373, -73.92644992133326 40.69200176882866, -73.92631612531525 40.69192845396802, -73.92556064122292 40.691490840003, -73.92534903613239 40.69136694183798, -73.92439183303664 40.69083174877439, -73.92429213268012 40.69077335685399, -73.92364379835564 40.6903988375817, -73.92316966710699 40.69012340599072, -73.92280702359515 40.68992392534457, -73.92207133797079 40.68948984079818, -73.92130587808545 40.68907164359784, -73.92121369950202 40.68901947711544, -73.92096103866248 40.68887205183747, -73.92055013077213 40.68864092211603, -73.91980961874593 40.6882112414115, -73.91906109224908 40.68778436875932, -73.91878323293736 40.68762608844376, -73.91829345832642 40.68735666781527, -73.91804606958546 40.68721324726834, -73.91768113918805 40.68700409429878, -73.91755226067554 40.68693022304933, -73.91679832884886 40.68649719987184, -73.91679482480477 40.68647585566188, -73.91677745031008 40.68637001456988, -73.9167269298151 40.6861315560806, -73.91739374561757 40.68605758524438, -73.91784937410198 40.68623316741141, -73.91800616261635 40.6858220326253, -73.91770109452972 40.68550035866507, -73.9178810736956 40.68509394091895, -73.91755763291395 40.68476719192117, -73.91776142009367 40.68432465483016, -73.91741294336087 40.68403405152289, -73.91758679937763 40.68391130921148, -73.91754176551858 40.68365836480015, -73.91749199778137 40.68340840097156, -73.91726632656643 40.68330322455323, -73.91748255687848 40.68289735539763, -73.91712138528143 40.68256847168654, -73.91732345753172 40.68244571271426, -73.9172785838021 40.68218148175983, -73.91722749280017 40.68193500491278, -73.9169763289098 40.68183415891587, -73.91717325370381 40.68163401677827, -73.91713117516936 40.68143498166116, -73.91708045205013 40.68119847288923, -73.91683011483136 40.68110098072739, -73.91676207442167 40.68075559994087, -73.91668638370811 40.68037137878948, -73.9165399872181 40.67963749735295, -73.91639300075401 40.67890584888099, -73.91630119795475 40.67857711243357, -73.91635492184039 40.6778235366874, -73.91645747530021 40.67672602823275, -73.91646486032333 40.67664704004651, -73.91647371343048 40.67655700413084, -73.91654436298559 40.67583843461703, -73.91661697848021 40.67505994757939, -73.91668911898741 40.67428057620312, -73.91677231309316 40.67339069306274, -73.91721449620965 40.67385599371995, -73.91907827608151 40.67397531376398, -73.91954092546408 40.67354187795393, -73.9200025573228 40.67398128283877, -73.92158580075649 40.67405555683759, -73.92213153379178 40.67368388950964, -73.92298622413946 40.67373038435373, -73.92309797315002 40.67373646296576, -73.92324436873267 40.67374442565551, -73.92336008453272 40.67375071908456, -73.92508152301917 40.67384433817344, -73.92550081445938 40.67361688849451, -73.92743998148244 40.67370890462769, -73.92784085188026 40.67399598368088, -73.92788485920073 40.67355077838425, -73.92792887672408 40.67310556484484, -73.9282445167355 40.67293933694761, -73.9282717980865 40.67252471210702, -73.92801317657924 40.67220920817189, -73.92826528535652 40.67222507724347, -73.92833507240064 40.67222889379835, -73.92843446083054 40.67223432828423, -73.92851854078968 40.67223892474855, -73.92862604211787 40.67224480269724, -73.92870956326151 40.67224936969293, -73.92882833736527 40.67225586323351, -73.92891232629145 40.67226045499795, -73.92939948737151 40.67228708901998, -73.9307932883315 40.67236495699643, -73.93355357161703 40.67251450202632, -73.9363431994143 40.67269957696197, -73.93667540626117 40.6727143953574, -73.93682717835949 40.67271928165021, -73.93708255238936 40.67272750062104, -73.93754574483314 40.672742485227, -73.93753568983917 40.67332211170566, -73.93753114689092 40.67358374466557, -73.93752485721895 40.67394597310864, -73.93751992857378 40.67422980176767, -73.93806258654983 40.67447201037736, -73.93832822275243 40.67458578836195, -73.93889518673745 40.67459873386304, -73.93877769674783 40.67472089131839, -73.93873696341934 40.67538905896871, -73.93884149817444 40.67549215171548, -73.93843297207545 40.67556514632768, -73.93852793096612 40.67617239034053, -73.93876783935517 40.67627240938755, -73.93853686439037 40.67634626398586, -73.93843334915296 40.67693817086859, -73.9386949143591 40.67705082000203, -73.93851537899995 40.67741865687472, -73.93863289914781 40.67776992010254, -73.93862492563589 40.67786256958296, -73.9386168305744 40.67794381002248, -73.93850818855235 40.67903432002991, -73.93843613326652 40.67978585170399, -73.93739763665229 40.67972990017674, -73.93764243456839 40.68096300863983, -73.93778801579033 40.68169433234844, -73.9348625715524 40.68203056869989, -73.93500821720075 40.68276376850579, -73.93515472893986 40.68349718465807, -73.93807695931454 40.68316090298936, -73.9382232586039 40.68389329800515, -73.93836816506894 40.68462560189113, -73.93851929553905 40.68535451524578, -73.93865905188188 40.68609038907362, -73.93880456947376 40.68682474574926, -73.93895074350998 40.68755641035276, -73.93938561082579 40.68787113499809, -73.9413859614605 40.6876682688049, -73.94178527584324 40.68722837212115, -73.9423520278467 40.68759150082202, -73.94428391577316 40.68738505531383, -73.94462127846789 40.68690436166384, -73.94471297541574 40.68737334166219, -73.94472684342399 40.68744426893098, -73.94476925905255 40.6876366000215, -73.94489497385723 40.68828685373113, -73.94491170954201 40.68837022260124, -73.94505645129829 40.68910234632374, -73.94519881242742 40.68983988030254, -73.94534976297854 40.69056729694257, -73.94549553209639 40.69130013188384, -73.94564166805849 40.69203345190423, -73.94578713653169 40.69276523278351, -73.94593170750511 40.69349761558435, -73.94607851790597 40.69423024360605, -73.94324249086142 40.69455748523078, -73.94338802084518 40.69528898951384, -73.94352527471476 40.69603085523811, -73.94335303762136 40.69605059879613, -73.94321604415771 40.69606631370468, -73.94279300209647 40.69611479586432, -73.94242149063366 40.69615738067107, -73.9423368032754 40.69616708769403, -73.94226167920422 40.696175698798, -73.94217061244066 40.69618613693807, -73.94208643350876 40.69619578590027, -73.94198436724183 40.69620748536691, -73.94152445883948 40.6962601986313, -73.94070625153131 40.69635305387921, -73.94040726721202 40.69638987090211, -73.94020994337993 40.69641107787343, -73.94003822508267 40.69643083533578, -73.93976769964368 40.69646329104629, -73.93948446000253 40.69649454647407, -73.93917199789162 40.69653049512544, -73.93884866773332 40.69656769159932, -73.93867948785814 40.69658715370254, -73.93779110726068 40.69668934223279, -73.93763027449141 40.69595086258837, -73.93755700214285 40.69558451152044, -73.93748376644189 40.6952184321377, -73.9370544081801 40.69553123358047, -73.9348298043286 40.69575489184654, -73.9345601174396 40.69555483174558, -73.93463155014204 40.69592163383321, -73.93470512606679 40.69628830975414, -73.9347969968416 40.69673659235447, -73.93468892593663 40.69667495388458, -73.9346067517839 40.69662808583959, -73.93457999376531 40.69661282447046, -73.93448784825009 40.69656026847871, -73.93413397294013 40.69635843140355, -73.93382817155928 40.69618427730787, -73.93311862859143 40.69579115384632))'
school_table.WKT[0]
'POINT (-73.978747 40.722075)'
len(dist_table.school_dis.unique())
32
# aggregate districts
from shapely import wkt
import numpy as np
district_polygons = dist_table['geometry_object']
def get_district(geometry_wkt):
g = wkt.loads(geometry_wkt)
#flags = [x.contains(g) for x in district_polygons]
flags = [x.intersects(g) for x in district_polygons]
index = np.argmax(flags)
district = int(dist_table.iloc[index]['school_dis'])
return district
school_table['district'] = school_table['WKT'].apply(get_district)
len(school_table.district.unique())
32
len(dist_table)
33
mean_table = school_table.groupby('district').mean()
mean_table = mean_table.reset_index()
mean_table = mean_table[[
'district',
'economic_need_index',
]]
t = pd.merge(dist_table, mean_table, left_on='school_dis', right_on='district')
map_table = t.copy()
map_table['FillBlues'] = map_table.economic_need_index
school_map_table = school_table.copy()
school_map_table['geometry_object'] = school_map_table.WKT.apply(wkt.loads)
district_map_table = t.copy()
district_map_table['FillBlues'] = district_map_table['economic_need_index']
school_map_table = school_table.copy()
#school_map_table['FillBlues'] = district_map_table['economic_need_index'].max()
map_table = pd.concat([
#district_map_table,
school_map_table,
], sort=False)
url = 'https://data.cityofnewyork.us/api/views/vh2h-md7a/rows.csv'
school_graduation_table = pd.read_csv(url)
len(school_graduation_table)
25096
school_graduation_table.iloc[0]
Demographic Total Cohort DBN 01M292 School Name HENRY STREET SCHOOL FOR INTERNATIONAL Cohort 2003 Total Cohort 5 Total Grads - n s Total Grads - % of cohort NaN Total Regents - n s Total Regents - % of cohort NaN Total Regents - % of grads NaN Advanced Regents - n s Advanced Regents - % of cohort NaN Advanced Regents - % of grads NaN Regents w/o Advanced - n s Regents w/o Advanced - % of cohort NaN Regents w/o Advanced - % of grads NaN Local - n s Local - % of cohort NaN Local - % of grads NaN Still Enrolled - n s Still Enrolled - % of cohort NaN Dropped Out - n s Dropped Out - % of cohort NaN Name: 0, dtype: object
school_graduation_table.groupby('DBN').mean()[:5]
Total Cohort | Total Grads - % of cohort | Total Regents - % of cohort | Total Regents - % of grads | Advanced Regents - % of cohort | Advanced Regents - % of grads | Regents w/o Advanced - % of cohort | Regents w/o Advanced - % of grads | Local - % of cohort | Local - % of grads | Still Enrolled - % of cohort | Dropped Out - % of cohort | |
---|---|---|---|---|---|---|---|---|---|---|---|---|
DBN | ||||||||||||
01M292 | 25.870370 | 61.755556 | 42.737037 | 70.448148 | 0.000000 | 0.000000 | 42.737037 | 70.448148 | 19.000000 | 29.551852 | 20.337037 | 12.100000 |
01M448 | 44.051948 | 58.637736 | 36.352830 | 61.415094 | 8.462264 | 13.481132 | 27.884906 | 47.928302 | 22.281132 | 38.588679 | 28.264151 | 9.958491 |
01M450 | 36.565789 | 70.462500 | 66.075000 | 93.714583 | 0.000000 | 0.000000 | 66.075000 | 93.714583 | 4.383333 | 6.285417 | 18.210417 | 9.985417 |
01M509 | 34.797297 | 49.902381 | 31.861905 | 61.852381 | 10.540476 | 19.133333 | 21.321429 | 42.711905 | 18.028571 | 38.150000 | 30.502381 | 14.266667 |
01M515 | 87.876712 | 49.151064 | 36.508511 | 74.361702 | 21.876596 | 44.129787 | 14.631915 | 30.225532 | 12.725532 | 25.787234 | 34.219149 | 16.370213 |
school_graduation_table = school_graduation_table[['DBN', 'School Name', 'Total Grads - % of cohort']].copy()
len(school_graduation_table)
25096
school_graduation_table = school_graduation_table.dropna()
sum(school_graduation_table['Total Grads - % of cohort'] == 's')
/home/user/.virtualenvs/crosscompute/lib/python3.6/site-packages/pandas/core/ops.py:1649: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison result = method(y)
0
# Define which values mean null
school_graduation_table = pd.read_csv(url, na_values=['s'])
school_graduation_table = school_graduation_table[['DBN', 'School Name', 'Total Grads - % of cohort']].copy()
school_graduation_table = school_graduation_table.dropna()
school_graduation_table = school_graduation_table.rename(
columns={'Total Grads - % of cohort': 'Graduation Rate'})
len(school_graduation_table)
16704
school_graduation_table.dtypes
DBN object School Name object Graduation Rate float64 dtype: object
school_graduation_table
DBN | School Name | Graduation Rate | |
---|---|---|---|
1 | 01M292 | HENRY STREET SCHOOL FOR INTERNATIONAL | 67.3 |
2 | 01M292 | HENRY STREET SCHOOL FOR INTERNATIONAL | 67.2 |
3 | 01M292 | HENRY STREET SCHOOL FOR INTERNATIONAL | 55.1 |
4 | 01M292 | HENRY STREET SCHOOL FOR INTERNATIONAL | 56.4 |
5 | 01M448 | UNIVERSITY NEIGHBORHOOD HIGH SCHOOL | 71.9 |
6 | 01M448 | UNIVERSITY NEIGHBORHOOD HIGH SCHOOL | 63.5 |
7 | 01M448 | UNIVERSITY NEIGHBORHOOD HIGH SCHOOL | 77.0 |
8 | 01M448 | UNIVERSITY NEIGHBORHOOD HIGH SCHOOL | 67.0 |
9 | 01M448 | UNIVERSITY NEIGHBORHOOD HIGH SCHOOL | 52.9 |
10 | 01M448 | UNIVERSITY NEIGHBORHOOD HIGH SCHOOL | 42.7 |
11 | 01M448 | UNIVERSITY NEIGHBORHOOD HIGH SCHOOL | 48.4 |
12 | 01M450 | EAST SIDE COMMUNITY SCHOOL | 67.2 |
13 | 01M450 | EAST SIDE COMMUNITY SCHOOL | 62.5 |
14 | 01M450 | EAST SIDE COMMUNITY SCHOOL | 62.0 |
15 | 01M450 | EAST SIDE COMMUNITY SCHOOL | 72.5 |
16 | 01M450 | EAST SIDE COMMUNITY SCHOOL | 71.8 |
17 | 01M450 | EAST SIDE COMMUNITY SCHOOL | 77.8 |
18 | 01M450 | EAST SIDE COMMUNITY SCHOOL | 78.9 |
19 | 01M509 | MARTA VALLE HIGH SCHOOL | 49.3 |
20 | 01M509 | MARTA VALLE HIGH SCHOOL | 40.0 |
21 | 01M509 | MARTA VALLE HIGH SCHOOL | 44.3 |
22 | 01M509 | MARTA VALLE HIGH SCHOOL | 44.6 |
23 | 01M509 | MARTA VALLE HIGH SCHOOL | 55.7 |
24 | 01M509 | MARTA VALLE HIGH SCHOOL | 56.0 |
25 | 01M509 | MARTA VALLE HIGH SCHOOL | 59.5 |
26 | 01M515 | LOWER EAST SIDE PREPARATORY HIGH SCHO | 53.0 |
27 | 01M515 | LOWER EAST SIDE PREPARATORY HIGH SCHO | 44.8 |
28 | 01M515 | LOWER EAST SIDE PREPARATORY HIGH SCHO | 42.0 |
29 | 01M515 | LOWER EAST SIDE PREPARATORY HIGH SCHO | 48.5 |
30 | 01M515 | LOWER EAST SIDE PREPARATORY HIGH SCHO | 45.5 |
... | ... | ... | ... |
25060 | 32K545 | EBC HIGH SCHOOL FOR PUBLIC SERVICE?BU | 58.6 |
25061 | 32K545 | EBC HIGH SCHOOL FOR PUBLIC SERVICE?BU | 50.0 |
25062 | 32K545 | EBC HIGH SCHOOL FOR PUBLIC SERVICE?BU | 60.3 |
25063 | 32K545 | EBC HIGH SCHOOL FOR PUBLIC SERVICE?BU | 56.2 |
25064 | 32K545 | EBC HIGH SCHOOL FOR PUBLIC SERVICE?BU | 63.0 |
25066 | 32K549 | BUSHWICK SCHOOL FOR SOCIAL JUSTICE | 57.1 |
25067 | 32K549 | BUSHWICK SCHOOL FOR SOCIAL JUSTICE | 70.4 |
25068 | 32K549 | BUSHWICK SCHOOL FOR SOCIAL JUSTICE | 69.4 |
25069 | 32K549 | BUSHWICK SCHOOL FOR SOCIAL JUSTICE | 71.1 |
25070 | 32K549 | BUSHWICK SCHOOL FOR SOCIAL JUSTICE | 71.1 |
25072 | 32K552 | ACADEMY OF URBAN PLANNING | 49.2 |
25073 | 32K552 | ACADEMY OF URBAN PLANNING | 53.2 |
25074 | 32K552 | ACADEMY OF URBAN PLANNING | 52.8 |
25075 | 32K552 | ACADEMY OF URBAN PLANNING | 42.0 |
25076 | 32K552 | ACADEMY OF URBAN PLANNING | 54.0 |
25080 | 32K554 | ALL CITY LEADERSHIP SECONDARY SCHOOL | 69.6 |
25081 | 32K554 | ALL CITY LEADERSHIP SECONDARY SCHOOL | 87.5 |
25082 | 32K554 | ALL CITY LEADERSHIP SECONDARY SCHOOL | 91.7 |
25084 | 32K556 | BUSHWICK LEADERS HIGH SCHOOL FOR ACAD | 63.8 |
25085 | 32K556 | BUSHWICK LEADERS HIGH SCHOOL FOR ACAD | 64.7 |
25086 | 32K556 | BUSHWICK LEADERS HIGH SCHOOL FOR ACAD | 62.5 |
25087 | 32K556 | BUSHWICK LEADERS HIGH SCHOOL FOR ACAD | 49.0 |
25088 | 32K556 | BUSHWICK LEADERS HIGH SCHOOL FOR ACAD | 51.0 |
25089 | 32K564 | BUSHWICK COMMUNITY HIGH SCHOOL | 2.9 |
25090 | 32K564 | BUSHWICK COMMUNITY HIGH SCHOOL | 5.5 |
25091 | 32K564 | BUSHWICK COMMUNITY HIGH SCHOOL | 1.5 |
25092 | 32K564 | BUSHWICK COMMUNITY HIGH SCHOOL | 3.1 |
25093 | 32K564 | BUSHWICK COMMUNITY HIGH SCHOOL | 3.8 |
25094 | 32K564 | BUSHWICK COMMUNITY HIGH SCHOOL | 7.0 |
25095 | 32K564 | BUSHWICK COMMUNITY HIGH SCHOOL | 7.0 |
school_graduation_table = school_graduation_table.groupby('DBN').mean()
school_graduation_table[:5]
Graduation Rate | |
---|---|
DBN | |
01M292 | 61.755556 |
01M448 | 58.637736 |
01M450 | 70.462500 |
01M509 | 49.902381 |
01M515 | 49.151064 |
endpoint_url = 'https://data.cityofnewyork.us/resource/r2nx-nhxe.csv'
# Load schools
school_location_table = load(
endpoint_url,
buffer_size=1000)
school_location_table[:5]
https://data.cityofnewyork.us/resource/r2nx-nhxe.csv?$limit=1000 1000 1823
:@computed_region_92fq_4b7q | :@computed_region_efsh_h5xi | :@computed_region_f5dn_yrer | :@computed_region_sbqj_enih | :@computed_region_yeji_bk3q | admin_district_location_code | administrative_district_name | ats_system_code | beds_number | borough_block_lot | ... | primary_building_code | principal_name | principal_phone_number | principal_title | school_support_team_leader_name | school_support_team_name | state_code | status_descriptions | x_coordinate | y_coordinate | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 50.0 | 11729.0 | 70.0 | 5.0 | 4.0 | M801 | COMMUNITY SCHOOL DISTRICT 01 | 01M015 | 310100010015 | 1003740020 | ... | M015 | IRENE SANCHEZ | 212-228-8730 | PRINCIPAL | NaN | School Support Team 3- Manhattan | NY | Open | 990141.0 | 202349.0 |
1 | 50.0 | 11724.0 | 70.0 | 5.0 | 4.0 | M801 | COMMUNITY SCHOOL DISTRICT 01 | 01M019 | 310100010019 | 1004530034 | ... | M019 | JACQUELINE FLANAGAN | 212-533-5340 | PRINCIPAL | NaN | School Support Team 3- Manhattan | NY | Open | 988547.0 | 205239.0 |
2 | 32.0 | 11723.0 | 70.0 | 4.0 | 4.0 | M801 | COMMUNITY SCHOOL DISTRICT 01 | 01M020 | 310100010020 | 1003550001 | ... | M020 | SARAH PINTO VIAGRAN | 212-254-9577 | PRINCIPAL | NaN | School Support Team 3- Manhattan | NY | Open | 988044.0 | 202068.0 |
3 | 50.0 | 11729.0 | 70.0 | 5.0 | 4.0 | M801 | COMMUNITY SCHOOL DISTRICT 01 | 01M034 | 310100010034 | 1003810038 | ... | M034 | ANGELIKI LOUKATOS | 212-228-4433 | PRINCIPAL | NaN | School Support Team 3- Manhattan | NY | Open | 991163.0 | 203782.0 |
4 | 50.0 | 11729.0 | 70.0 | 5.0 | 4.0 | M801 | COMMUNITY SCHOOL DISTRICT 01 | 01M063 | 310100010063 | 1004310014 | ... | M063 | DARLENE CAMERON | 212-674-3180 | PRINCIPAL | NaN | School Support Team 3- Manhattan | NY | Open | 988071.0 | 203210.0 |
school_location_table.iloc[0]
:@computed_region_92fq_4b7q 50 :@computed_region_efsh_h5xi 11729 :@computed_region_f5dn_yrer 70 :@computed_region_sbqj_enih 5 :@computed_region_yeji_bk3q 4 admin_district_location_code M801 administrative_district_name COMMUNITY SCHOOL DISTRICT 01 ats_system_code 01M015 beds_number 310100010015 borough_block_lot 1003740020 census_tract 2601 community_district 103 community_school_sup_name PHILLIPS, DANIELLA council_district 2 fax_number 212-477-0931 field_support_center_leader_name CHU, YUET field_support_center_name Field Support Center - Manhattan fiscal_year 2018 geographical_district_code 1 grades_final_text PK,0K,01,02,03,04,05 grades_text PK,0K,01,02,03,04,05,SE highschool_network_location_code NaN highschool_network_name NaN highschool_network_superintendent NaN location_1 POINT (-73.978747 40.722075) location_1_address 333 EAST 4 STREET location_1_city MANHATTAN location_1_state NY location_1_zip 10009 location_category_description Elementary location_code M015 location_name P.S. 015 Roberto Clemente location_type_description General Academic managed_by_name DOE nta MN28 nta_name Lower East Side ... open_date 1904-07-01T00:00:00.000 primary_address_line_1 333 EAST 4 STREET primary_building_code M015 principal_name IRENE SANCHEZ principal_phone_number 212-228-8730 principal_title PRINCIPAL school_support_team_leader_name NaN school_support_team_name School Support Team 3- Manhattan state_code NY status_descriptions Open x_coordinate 990141 y_coordinate 202349 Name: 0, dtype: object
school_location_table.iloc[0]['location_1']
'POINT (-73.978747 40.722075)'
school_location_table.iloc[0]['ats_system_code']
'01M015 '
school_location_table['DBN'] = school_location_table['ats_system_code'].str.strip()
school_location_table.iloc[0]['DBN']
'01M015'
school_location_table = school_location_table.rename(columns={
'location_1': 'WKT',
'location_name': 'School Name',
})
trimmed_school_location_table = school_location_table[[
'DBN',
'WKT',
'School Name',
]]
merged_school_table = pd.merge(
school_table,
school_graduation_table,
left_on='DBN',
right_on='DBN')
len(school_table)
7173
merged_school_table.iloc[0]
DBN 01M292 WKT POINT (-73.986051 40.713362) School Name Orchard Collegiate Academy asian_1 32 asian_2 12.5 black_1 66 black_2 25.9 dbn 01M292 economic_need_index 83.9 english_language_learners_1 30 english_language_learners_2 11.8 female_1 96 female_2 37.6 grade_1 0 grade_10 52 grade_11 36 grade_12 58 grade_2 0 grade_3 0 grade_4 0 grade_5 0 grade_6 17 grade_7 14 grade_8 19 grade_9 59 grade_k 0 grade_pk_half_day_full_day 0 hispanic_1 142 hispanic_2 55.7 male_1 159 male_2 62.4 multiple_race_categories_not_represented_1 6 multiple_race_categories_not_represented_2 2.4 poverty_1 227 poverty_2 89 school_name Orchard Collegiate Academy students_with_disabilities_1 83 students_with_disabilities_2 32.5 total_enrollment 255 white_1 9 white_2 3.5 year 2014-15 Diversity Index 83.9 district 1 Graduation Rate 61.7556 Name: 0, dtype: object
sorted_school_table = merged_school_table.sort_values('Graduation Rate', ascending=False)
sorted_school_table[:3]
DBN | WKT | School Name | asian_1 | asian_2 | black_1 | black_2 | dbn | economic_need_index | english_language_learners_1 | ... | school_name | students_with_disabilities_1 | students_with_disabilities_2 | total_enrollment | white_1 | white_2 | year | Diversity Index | district | Graduation Rate | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1085 | 25Q525 | POINT (-73.821532 40.737038) | Townsend Harris High School | 663 | 58.5 | 64 | 5.6 | 25Q525 | 28.2 | 0 | ... | Townsend Harris High School | 19 | 1.7 | 1133 | 247 | 21.8 | 2015-16 | 28.2 | 25 | 99.552632 |
1086 | 25Q525 | POINT (-73.821532 40.737038) | Townsend Harris High School | 644 | 58.0 | 60 | 5.4 | 25Q525 | 26.1 | 0 | ... | Townsend Harris High School | 29 | 2.6 | 1110 | 234 | 21.1 | 2016-17 | 26.1 | 25 | 99.552632 |
1087 | 25Q525 | POINT (-73.821532 40.737038) | Townsend Harris High School | 662 | 58.0 | 59 | 5.2 | 25Q525 | 38.5 | 0 | ... | Townsend Harris High School | 40 | 3.5 | 1141 | 231 | 20.2 | 2017-18 | 38.5 | 25 | 99.552632 |
sorted_school_table[-3:]
DBN | WKT | School Name | asian_1 | asian_2 | black_1 | black_2 | dbn | economic_need_index | english_language_learners_1 | ... | school_name | students_with_disabilities_1 | students_with_disabilities_2 | total_enrollment | white_1 | white_2 | year | Diversity Index | district | Graduation Rate | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
728 | 13K616 | POINT (-73.95818 40.692015) | Brooklyn High School for Leadership and Community | 2 | 0.9 | 155 | 70.8 | 13K616 | 75.1 | 8 | ... | Brooklyn High School for Leadership and Community | 43 | 19.6 | 219 | 3 | 1.4 | 2014-15 | 75.1 | 13 | 5.322222 |
731 | 13K616 | POINT (-73.95818 40.692015) | Brooklyn High School for Leadership and Community | 3 | 1.5 | 140 | 68.3 | 13K616 | 84.5 | 12 | ... | Brooklyn High School for Leadership and Community | 42 | 20.5 | 205 | 2 | 1.0 | 2017-18 | 84.5 | 13 | 5.322222 |
729 | 13K616 | POINT (-73.95818 40.692015) | Brooklyn High School for Leadership and Community | 1 | 0.4 | 161 | 70.0 | 13K616 | 71.6 | 11 | ... | Brooklyn High School for Leadership and Community | 37 | 16.1 | 230 | 4 | 1.7 | 2015-16 | 71.6 | 13 | 5.322222 |
school_table.iloc[0]
DBN 01M015 WKT POINT (-73.978747 40.722075) School Name P.S. 015 Roberto Clemente asian_1 8 asian_2 4.4 black_1 65 black_2 35.5 dbn 01M015 economic_need_index 93.5 english_language_learners_1 17 english_language_learners_2 9.3 female_1 84 female_2 45.9 grade_1 47 grade_10 0 grade_11 0 grade_12 0 grade_2 31 grade_3 19 grade_4 17 grade_5 24 grade_6 0 grade_7 0 grade_8 0 grade_9 0 grade_k 27 grade_pk_half_day_full_day 18 hispanic_1 107 hispanic_2 58.5 male_1 99 male_2 54.1 multiple_race_categories_not_represented_1 1 multiple_race_categories_not_represented_2 0.5 poverty_1 169 poverty_2 92.3 school_name P.S. 015 Roberto Clemente students_with_disabilities_1 64 students_with_disabilities_2 35 total_enrollment 183 white_1 2 white_2 1.1 year 2014-15 Diversity Index 93.5 district 1 Name: 0, dtype: object
# INSERTED FROM HERE
a_school_map_table = sorted_school_table[:100].copy()
a_school_map_table = a_school_map_table[['WKT', 'School Name']]
a_school_map_table = a_school_map_table.rename({
'School Name': 'Name',
})
a_school_map_table['FillColor'] = 'g'
b_school_map_table = sorted_school_table[-100:].copy()
b_school_map_table = b_school_map_table[['WKT', 'School Name']]
b_school_map_table = b_school_map_table.rename({
'School Name': 'Name',
})
b_school_map_table['FillColor'] = 'r'
t = pd.merge(dist_table, mean_table, left_on='school_dis', right_on='district')
t[:3]
school_dis | shape_area | shape_leng | geometry_object | geometry_layer | geometry_proj4 | district | economic_need_index | |
---|---|---|---|---|---|---|---|---|
0 | 16.0 | 4.676362e+07 | 35848.904605 | POLYGON ((-73.93311862859143 40.69579115384632... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 16 | 79.038028 |
1 | 32.0 | 5.189850e+07 | 37251.057847 | POLYGON ((-73.91180710069435 40.70343495202662... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 32 | 81.194444 |
2 | 6.0 | 9.634170e+07 | 70447.849084 | POLYGON ((-73.92640556921116 40.87762147653734... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 6 | 77.312322 |
district_map_table = t.copy()
district_map_table['WKT'] = district_map_table['geometry_object'].apply(
lambda x: x.wkt)
# Define FillColor
from sklearn.preprocessing import MinMaxScaler
scaler = MinMaxScaler(feature_range=(1, 100))
array = district_map_table['economic_need_index'].values.reshape(-1, 1)
scaler.fit(array)
district_map_table['scaled_index'] = scaler.transform(array)
district_map_table.head()
school_dis | shape_area | shape_leng | geometry_object | geometry_layer | geometry_proj4 | district | economic_need_index | WKT | scaled_index | |
---|---|---|---|---|---|---|---|---|---|---|
0 | 16.0 | 4.676362e+07 | 35848.904605 | POLYGON ((-73.93311862859143 40.69579115384632... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 16 | 79.038028 | POLYGON ((-73.93311862859143 40.69579115384632... | 84.226077 |
1 | 32.0 | 5.189850e+07 | 37251.057847 | POLYGON ((-73.91180710069435 40.70343495202662... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 32 | 81.194444 | POLYGON ((-73.91180710069435 40.70343495202662... | 88.344579 |
2 | 6.0 | 9.634170e+07 | 70447.849084 | POLYGON ((-73.92640556921116 40.87762147653734... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 6 | 77.312322 | POLYGON ((-73.92640556921116 40.87762147653734... | 80.930181 |
3 | 31.0 | 1.604472e+09 | 434471.412859 | (POLYGON ((-74.05050806403247 40.5664220341608... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 31 | 49.263141 | MULTIPOLYGON (((-74.05050806403247 40.56642203... | 27.359534 |
4 | 8.0 | 2.588266e+08 | 223080.142631 | (POLYGON ((-73.83979488562171 40.8356192074928... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 8 | 78.060000 | MULTIPOLYGON (((-73.83979488562171 40.83561920... | 82.358158 |
district_map_table.loc[district_map_table['scaled_index'] < 25, 'FillColor'] = '#ADD8E6'
district_map_table.loc[(district_map_table['scaled_index'] >= 25)
& (district_map_table['scaled_index'] < 50), 'FillColor'] = '#0000FF'
district_map_table.loc[(district_map_table['scaled_index'] >= 50)
& (district_map_table['scaled_index'] < 75), 'FillColor'] = '#0440FF'
district_map_table.loc[(district_map_table['scaled_index'] >= 75)
& (district_map_table['scaled_index'] < 100), 'FillColor'] = '#0660FF'
district_map_table
school_dis | shape_area | shape_leng | geometry_object | geometry_layer | geometry_proj4 | district | economic_need_index | WKT | scaled_index | FillColor | |
---|---|---|---|---|---|---|---|---|---|---|---|
0 | 16.0 | 4.676362e+07 | 35848.904605 | POLYGON ((-73.93311862859143 40.69579115384632... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 16 | 79.038028 | POLYGON ((-73.93311862859143 40.69579115384632... | 84.226077 | #0660FF |
1 | 32.0 | 5.189850e+07 | 37251.057847 | POLYGON ((-73.91180710069435 40.70343495202662... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 32 | 81.194444 | POLYGON ((-73.91180710069435 40.70343495202662... | 88.344579 | #0660FF |
2 | 6.0 | 9.634170e+07 | 70447.849084 | POLYGON ((-73.92640556921116 40.87762147653734... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 6 | 77.312322 | POLYGON ((-73.92640556921116 40.87762147653734... | 80.930181 | #0660FF |
3 | 31.0 | 1.604472e+09 | 434471.412859 | (POLYGON ((-74.05050806403247 40.5664220341608... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 31 | 49.263141 | MULTIPOLYGON (((-74.05050806403247 40.56642203... | 27.359534 | #0000FF |
4 | 8.0 | 2.588266e+08 | 223080.142631 | (POLYGON ((-73.83979488562171 40.8356192074928... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 8 | 78.060000 | MULTIPOLYGON (((-73.83979488562171 40.83561920... | 82.358158 | #0660FF |
5 | 7.0 | 9.226247e+07 | 65294.452403 | (POLYGON ((-73.89680883223774 40.7958084451597... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 7 | 85.659751 | MULTIPOLYGON (((-73.89680883223774 40.79580844... | 96.872791 | #0660FF |
6 | 23.0 | 4.740069e+07 | 40317.452033 | (POLYGON ((-73.92044366203014 40.6656262871675... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 23 | 80.548125 | MULTIPOLYGON (((-73.92044366203014 40.66562628... | 87.110185 | #0660FF |
7 | 29.0 | 4.201981e+08 | 135035.241651 | POLYGON ((-73.73816144093141 40.72895809117297... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 29 | 52.408205 | POLYGON ((-73.73816144093141 40.72895809117297... | 33.366237 | #0000FF |
8 | 26.0 | 4.247909e+08 | 125677.678898 | POLYGON ((-73.74344992332192 40.77824115291502... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 26 | 35.461491 | POLYGON ((-73.74344992332192 40.77824115291502... | 1.000000 | #ADD8E6 |
9 | 15.0 | 1.961534e+08 | 153439.165680 | POLYGON ((-73.98633135042395 40.69105051012824... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 15 | 56.116456 | POLYGON ((-73.98633135042395 40.69105051012824... | 40.448561 | #0000FF |
10 | 17.0 | 1.284414e+08 | 68341.398899 | POLYGON ((-73.92044366203014 40.6656262871675,... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 17 | 70.930000 | POLYGON ((-73.92044366203014 40.6656262871675,... | 68.740694 | #0440FF |
11 | 19.0 | 2.034175e+08 | 184183.167312 | (POLYGON ((-73.846736514711 40.60485301485166,... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 19 | 79.049174 | MULTIPOLYGON (((-73.846736514711 40.6048530148... | 84.247363 | #0660FF |
12 | 27.0 | 7.955971e+08 | 589135.502728 | (POLYGON ((-73.82784008953526 40.5887858248046... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 27 | 61.418587 | MULTIPOLYGON (((-73.82784008953526 40.58878582... | 50.575011 | #0440FF |
13 | 13.0 | 1.048706e+08 | 86635.210559 | POLYGON ((-73.97906084911834 40.70594602894087... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 13 | 67.609955 | POLYGON ((-73.97906084911834 40.70594602894087... | 62.399797 | #0440FF |
14 | 18.0 | 1.751488e+08 | 121184.158477 | (POLYGON ((-73.86706149472118 40.5820879767934... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 18 | 63.183750 | MULTIPOLYGON (((-73.86706149472118 40.58208797... | 53.946265 | #0440FF |
15 | 20.0 | 2.426965e+08 | 94309.778946 | POLYGON ((-74.02552971543656 40.65147855069281... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 20 | 67.645238 | POLYGON ((-74.02552971543656 40.65147855069281... | 62.467184 | #0440FF |
16 | 3.0 | 1.134889e+08 | 52072.051321 | POLYGON ((-73.95671863064405 40.78660079332199... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 3 | 58.725581 | POLYGON ((-73.95671863064405 40.78660079332199... | 45.431685 | #0000FF |
17 | 5.0 | 5.251977e+07 | 44469.588221 | POLYGON ((-73.93515659239551 40.83268240623763... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 5 | 79.583051 | POLYGON ((-73.93515659239551 40.83268240623763... | 85.267006 | #0660FF |
18 | 9.0 | 8.341539e+07 | 46648.958586 | POLYGON ((-73.9212971968614 40.85428933985649,... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 9 | 87.297134 | POLYGON ((-73.9212971968614 40.85428933985649,... | 100.000000 | NaN |
19 | 1.0 | 3.516075e+07 | 28641.276279 | POLYGON ((-73.97177410965313 40.72582128133706... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 1 | 69.308088 | POLYGON ((-73.97177410965313 40.72582128133706... | 65.643032 | #0440FF |
20 | 14.0 | 1.503102e+08 | 95792.082090 | POLYGON ((-73.95439555417087 40.73911477252251... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 14 | 72.794898 | POLYGON ((-73.95439555417087 40.73911477252251... | 72.302430 | #0440FF |
21 | 2.0 | 2.804677e+08 | 214498.703163 | (POLYGON ((-74.0438776163991 40.69018767537123... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 2 | 53.006055 | MULTIPOLYGON (((-74.0438776163991 40.690187675... | 34.508060 | #0000FF |
22 | 4.0 | 5.262043e+07 | 52061.828459 | (POLYGON ((-73.92133752419399 40.8008521064970... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 4 | 78.418235 | MULTIPOLYGON (((-73.92133752419399 40.80085210... | 83.042345 | #0660FF |
23 | 10.0 | 2.825415e+08 | 94957.570537 | POLYGON ((-73.86789798628736 40.90294017690526... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 10 | 81.173067 | POLYGON ((-73.86789798628736 40.90294017690526... | 88.303750 | #0660FF |
24 | 10.0 | 3.282963e+06 | 7883.372664 | (POLYGON ((-73.9089323517538 40.8721573479701,... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 10 | 81.173067 | MULTIPOLYGON (((-73.9089323517538 40.872157347... | 88.303750 | #0660FF |
25 | 12.0 | 6.907182e+07 | 48527.595776 | POLYGON ((-73.88284445574813 40.84781722645163... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 12 | 86.122078 | POLYGON ((-73.88284445574813 40.84781722645163... | 97.755781 | #0660FF |
26 | 25.0 | 4.436285e+08 | 175827.007127 | POLYGON ((-73.82049919995312 40.80101146781899... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 25 | 49.729444 | POLYGON ((-73.82049919995312 40.80101146781899... | 28.250119 | #0000FF |
27 | 28.0 | 2.475679e+08 | 114694.912786 | POLYGON ((-73.84485477879177 40.7357514698091,... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 28 | 53.155288 | POLYGON ((-73.84485477879177 40.7357514698091,... | 34.793079 | #0000FF |
28 | 24.0 | 3.949782e+08 | 127343.703736 | (POLYGON ((-73.90641585511733 40.7398683641967... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 24 | 62.594286 | MULTIPOLYGON (((-73.90641585511733 40.73986836... | 52.820457 | #0440FF |
29 | 30.0 | 3.181290e+08 | 150392.978241 | POLYGON ((-73.90647314610101 40.79018117520807... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 30 | 59.615349 | POLYGON ((-73.90647314610101 40.79018117520807... | 47.131037 | #0000FF |
30 | 21.0 | 2.101971e+08 | 123858.087345 | POLYGON ((-73.96184657346174 40.62757081710622... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 21 | 66.737037 | POLYGON ((-73.96184657346174 40.62757081710622... | 60.732626 | #0440FF |
31 | 22.0 | 3.855533e+08 | 271718.504936 | (POLYGON ((-73.91990064270161 40.5996005215871... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 22 | 58.755000 | MULTIPOLYGON (((-73.91990064270161 40.59960052... | 45.487871 | #0000FF |
32 | 11.0 | 3.926651e+08 | 305305.863567 | (POLYGON ((-73.78833349834532 40.8346671297593... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 11 | 68.505313 | MULTIPOLYGON (((-73.78833349834532 40.83466712... | 64.109825 | #0440FF |
a_school_map_table = a_school_map_table.rename(columns={
'School Name': 'Name',
})
b_school_map_table = b_school_map_table.rename(columns={
'School Name': 'Name',
})
district_map_table['Name'] = district_map_table['district']
# Extract columns
# Extract columns
map_table = pd.concat([
a_school_map_table[['WKT','FillColor','Name']],
b_school_map_table[['WKT','FillColor','Name']],
district_map_table[['WKT','FillColor','Name']],
])
a_school_map_table[:3]
WKT | Name | FillColor | |
---|---|---|---|
1085 | POINT (-73.821532 40.737038) | Townsend Harris High School | g |
1086 | POINT (-73.821532 40.737038) | Townsend Harris High School | g |
1087 | POINT (-73.821532 40.737038) | Townsend Harris High School | g |
district_map_table
school_dis | shape_area | shape_leng | geometry_object | geometry_layer | geometry_proj4 | district | economic_need_index | WKT | scaled_index | FillColor | Name | |
---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 16.0 | 4.676362e+07 | 35848.904605 | POLYGON ((-73.93311862859143 40.69579115384632... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 16 | 79.038028 | POLYGON ((-73.93311862859143 40.69579115384632... | 84.226077 | #0660FF | 16 |
1 | 32.0 | 5.189850e+07 | 37251.057847 | POLYGON ((-73.91180710069435 40.70343495202662... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 32 | 81.194444 | POLYGON ((-73.91180710069435 40.70343495202662... | 88.344579 | #0660FF | 32 |
2 | 6.0 | 9.634170e+07 | 70447.849084 | POLYGON ((-73.92640556921116 40.87762147653734... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 6 | 77.312322 | POLYGON ((-73.92640556921116 40.87762147653734... | 80.930181 | #0660FF | 6 |
3 | 31.0 | 1.604472e+09 | 434471.412859 | (POLYGON ((-74.05050806403247 40.5664220341608... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 31 | 49.263141 | MULTIPOLYGON (((-74.05050806403247 40.56642203... | 27.359534 | #0000FF | 31 |
4 | 8.0 | 2.588266e+08 | 223080.142631 | (POLYGON ((-73.83979488562171 40.8356192074928... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 8 | 78.060000 | MULTIPOLYGON (((-73.83979488562171 40.83561920... | 82.358158 | #0660FF | 8 |
5 | 7.0 | 9.226247e+07 | 65294.452403 | (POLYGON ((-73.89680883223774 40.7958084451597... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 7 | 85.659751 | MULTIPOLYGON (((-73.89680883223774 40.79580844... | 96.872791 | #0660FF | 7 |
6 | 23.0 | 4.740069e+07 | 40317.452033 | (POLYGON ((-73.92044366203014 40.6656262871675... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 23 | 80.548125 | MULTIPOLYGON (((-73.92044366203014 40.66562628... | 87.110185 | #0660FF | 23 |
7 | 29.0 | 4.201981e+08 | 135035.241651 | POLYGON ((-73.73816144093141 40.72895809117297... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 29 | 52.408205 | POLYGON ((-73.73816144093141 40.72895809117297... | 33.366237 | #0000FF | 29 |
8 | 26.0 | 4.247909e+08 | 125677.678898 | POLYGON ((-73.74344992332192 40.77824115291502... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 26 | 35.461491 | POLYGON ((-73.74344992332192 40.77824115291502... | 1.000000 | #ADD8E6 | 26 |
9 | 15.0 | 1.961534e+08 | 153439.165680 | POLYGON ((-73.98633135042395 40.69105051012824... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 15 | 56.116456 | POLYGON ((-73.98633135042395 40.69105051012824... | 40.448561 | #0000FF | 15 |
10 | 17.0 | 1.284414e+08 | 68341.398899 | POLYGON ((-73.92044366203014 40.6656262871675,... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 17 | 70.930000 | POLYGON ((-73.92044366203014 40.6656262871675,... | 68.740694 | #0440FF | 17 |
11 | 19.0 | 2.034175e+08 | 184183.167312 | (POLYGON ((-73.846736514711 40.60485301485166,... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 19 | 79.049174 | MULTIPOLYGON (((-73.846736514711 40.6048530148... | 84.247363 | #0660FF | 19 |
12 | 27.0 | 7.955971e+08 | 589135.502728 | (POLYGON ((-73.82784008953526 40.5887858248046... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 27 | 61.418587 | MULTIPOLYGON (((-73.82784008953526 40.58878582... | 50.575011 | #0440FF | 27 |
13 | 13.0 | 1.048706e+08 | 86635.210559 | POLYGON ((-73.97906084911834 40.70594602894087... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 13 | 67.609955 | POLYGON ((-73.97906084911834 40.70594602894087... | 62.399797 | #0440FF | 13 |
14 | 18.0 | 1.751488e+08 | 121184.158477 | (POLYGON ((-73.86706149472118 40.5820879767934... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 18 | 63.183750 | MULTIPOLYGON (((-73.86706149472118 40.58208797... | 53.946265 | #0440FF | 18 |
15 | 20.0 | 2.426965e+08 | 94309.778946 | POLYGON ((-74.02552971543656 40.65147855069281... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 20 | 67.645238 | POLYGON ((-74.02552971543656 40.65147855069281... | 62.467184 | #0440FF | 20 |
16 | 3.0 | 1.134889e+08 | 52072.051321 | POLYGON ((-73.95671863064405 40.78660079332199... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 3 | 58.725581 | POLYGON ((-73.95671863064405 40.78660079332199... | 45.431685 | #0000FF | 3 |
17 | 5.0 | 5.251977e+07 | 44469.588221 | POLYGON ((-73.93515659239551 40.83268240623763... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 5 | 79.583051 | POLYGON ((-73.93515659239551 40.83268240623763... | 85.267006 | #0660FF | 5 |
18 | 9.0 | 8.341539e+07 | 46648.958586 | POLYGON ((-73.9212971968614 40.85428933985649,... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 9 | 87.297134 | POLYGON ((-73.9212971968614 40.85428933985649,... | 100.000000 | NaN | 9 |
19 | 1.0 | 3.516075e+07 | 28641.276279 | POLYGON ((-73.97177410965313 40.72582128133706... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 1 | 69.308088 | POLYGON ((-73.97177410965313 40.72582128133706... | 65.643032 | #0440FF | 1 |
20 | 14.0 | 1.503102e+08 | 95792.082090 | POLYGON ((-73.95439555417087 40.73911477252251... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 14 | 72.794898 | POLYGON ((-73.95439555417087 40.73911477252251... | 72.302430 | #0440FF | 14 |
21 | 2.0 | 2.804677e+08 | 214498.703163 | (POLYGON ((-74.0438776163991 40.69018767537123... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 2 | 53.006055 | MULTIPOLYGON (((-74.0438776163991 40.690187675... | 34.508060 | #0000FF | 2 |
22 | 4.0 | 5.262043e+07 | 52061.828459 | (POLYGON ((-73.92133752419399 40.8008521064970... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 4 | 78.418235 | MULTIPOLYGON (((-73.92133752419399 40.80085210... | 83.042345 | #0660FF | 4 |
23 | 10.0 | 2.825415e+08 | 94957.570537 | POLYGON ((-73.86789798628736 40.90294017690526... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 10 | 81.173067 | POLYGON ((-73.86789798628736 40.90294017690526... | 88.303750 | #0660FF | 10 |
24 | 10.0 | 3.282963e+06 | 7883.372664 | (POLYGON ((-73.9089323517538 40.8721573479701,... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 10 | 81.173067 | MULTIPOLYGON (((-73.9089323517538 40.872157347... | 88.303750 | #0660FF | 10 |
25 | 12.0 | 6.907182e+07 | 48527.595776 | POLYGON ((-73.88284445574813 40.84781722645163... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 12 | 86.122078 | POLYGON ((-73.88284445574813 40.84781722645163... | 97.755781 | #0660FF | 12 |
26 | 25.0 | 4.436285e+08 | 175827.007127 | POLYGON ((-73.82049919995312 40.80101146781899... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 25 | 49.729444 | POLYGON ((-73.82049919995312 40.80101146781899... | 28.250119 | #0000FF | 25 |
27 | 28.0 | 2.475679e+08 | 114694.912786 | POLYGON ((-73.84485477879177 40.7357514698091,... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 28 | 53.155288 | POLYGON ((-73.84485477879177 40.7357514698091,... | 34.793079 | #0000FF | 28 |
28 | 24.0 | 3.949782e+08 | 127343.703736 | (POLYGON ((-73.90641585511733 40.7398683641967... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 24 | 62.594286 | MULTIPOLYGON (((-73.90641585511733 40.73986836... | 52.820457 | #0440FF | 24 |
29 | 30.0 | 3.181290e+08 | 150392.978241 | POLYGON ((-73.90647314610101 40.79018117520807... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 30 | 59.615349 | POLYGON ((-73.90647314610101 40.79018117520807... | 47.131037 | #0000FF | 30 |
30 | 21.0 | 2.101971e+08 | 123858.087345 | POLYGON ((-73.96184657346174 40.62757081710622... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 21 | 66.737037 | POLYGON ((-73.96184657346174 40.62757081710622... | 60.732626 | #0440FF | 21 |
31 | 22.0 | 3.855533e+08 | 271718.504936 | (POLYGON ((-73.91990064270161 40.5996005215871... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 22 | 58.755000 | MULTIPOLYGON (((-73.91990064270161 40.59960052... | 45.487871 | #0000FF | 22 |
32 | 11.0 | 3.926651e+08 | 305305.863567 | (POLYGON ((-73.78833349834532 40.8346671297593... | geo_export_352ca16a-a10c-4e87-9f4d-882d44a87074 | +proj=longlat +ellps=WGS84 +no_defs | 11 | 68.505313 | MULTIPOLYGON (((-73.78833349834532 40.83466712... | 64.109825 | #0440FF | 11 |
type(district_map_table)
geotable.GeoTable
target_path = target_folder + '/choropleth.csv'
map_table.to_csv(target_path, index=False)
print('a_geotable_path = %s' % target_path)
a_geotable_path = /tmp/choropleth.csv
map_table
WKT | FillColor | Name | |
---|---|---|---|
1085 | POINT (-73.821532 40.737038) | g | Townsend Harris High School |
1086 | POINT (-73.821532 40.737038) | g | Townsend Harris High School |
1087 | POINT (-73.821532 40.737038) | g | Townsend Harris High School |
1084 | POINT (-73.821532 40.737038) | g | Townsend Harris High School |
111 | POINT (-73.953276 40.770288) | g | Eleanor Roosevelt High School |
110 | POINT (-73.953276 40.770288) | g | Eleanor Roosevelt High School |
109 | POINT (-73.953276 40.770288) | g | Eleanor Roosevelt High School |
108 | POINT (-73.953276 40.770288) | g | Eleanor Roosevelt High School |
23 | POINT (-73.979581 40.719416) | g | New Explorations into Science, Technology and ... |
22 | POINT (-73.979581 40.719416) | g | New Explorations into Science, Technology and ... |
21 | POINT (-73.979581 40.719416) | g | New Explorations into Science, Technology and ... |
20 | POINT (-73.979581 40.719416) | g | New Explorations into Science, Technology and ... |
94 | POINT (-73.985723 40.741888) | g | Baruch College Campus High School |
93 | POINT (-73.985723 40.741888) | g | Baruch College Campus High School |
92 | POINT (-73.985723 40.741888) | g | Baruch College Campus High School |
95 | POINT (-73.985723 40.741888) | g | Baruch College Campus High School |
296 | POINT (-73.947171 40.792932) | g | Young Women's Leadership School |
299 | POINT (-73.947171 40.792932) | g | Young Women's Leadership School |
297 | POINT (-73.947171 40.792932) | g | Young Women's Leadership School |
298 | POINT (-73.947171 40.792932) | g | Young Women's Leadership School |
141 | POINT (-74.013921 40.718025) | g | Stuyvesant High School |
140 | POINT (-74.013921 40.718025) | g | Stuyvesant High School |
142 | POINT (-74.013921 40.718025) | g | Stuyvesant High School |
143 | POINT (-74.013921 40.718025) | g | Stuyvesant High School |
1262 | POINT (-74.117086 40.568299) | g | Staten Island Technical High School |
1260 | POINT (-74.117086 40.568299) | g | Staten Island Technical High School |
1261 | POINT (-74.117086 40.568299) | g | Staten Island Technical High School |
1263 | POINT (-74.117086 40.568299) | g | Staten Island Technical High School |
568 | POINT (-73.889011 40.879958) | g | Bronx High School of Science |
569 | POINT (-73.889011 40.879958) | g | Bronx High School of Science |
... | ... | ... | ... |
3 | MULTIPOLYGON (((-74.05050806403247 40.56642203... | #0000FF | 31 |
4 | MULTIPOLYGON (((-73.83979488562171 40.83561920... | #0660FF | 8 |
5 | MULTIPOLYGON (((-73.89680883223774 40.79580844... | #0660FF | 7 |
6 | MULTIPOLYGON (((-73.92044366203014 40.66562628... | #0660FF | 23 |
7 | POLYGON ((-73.73816144093141 40.72895809117297... | #0000FF | 29 |
8 | POLYGON ((-73.74344992332192 40.77824115291502... | #ADD8E6 | 26 |
9 | POLYGON ((-73.98633135042395 40.69105051012824... | #0000FF | 15 |
10 | POLYGON ((-73.92044366203014 40.6656262871675,... | #0440FF | 17 |
11 | MULTIPOLYGON (((-73.846736514711 40.6048530148... | #0660FF | 19 |
12 | MULTIPOLYGON (((-73.82784008953526 40.58878582... | #0440FF | 27 |
13 | POLYGON ((-73.97906084911834 40.70594602894087... | #0440FF | 13 |
14 | MULTIPOLYGON (((-73.86706149472118 40.58208797... | #0440FF | 18 |
15 | POLYGON ((-74.02552971543656 40.65147855069281... | #0440FF | 20 |
16 | POLYGON ((-73.95671863064405 40.78660079332199... | #0000FF | 3 |
17 | POLYGON ((-73.93515659239551 40.83268240623763... | #0660FF | 5 |
18 | POLYGON ((-73.9212971968614 40.85428933985649,... | NaN | 9 |
19 | POLYGON ((-73.97177410965313 40.72582128133706... | #0440FF | 1 |
20 | POLYGON ((-73.95439555417087 40.73911477252251... | #0440FF | 14 |
21 | MULTIPOLYGON (((-74.0438776163991 40.690187675... | #0000FF | 2 |
22 | MULTIPOLYGON (((-73.92133752419399 40.80085210... | #0660FF | 4 |
23 | POLYGON ((-73.86789798628736 40.90294017690526... | #0660FF | 10 |
24 | MULTIPOLYGON (((-73.9089323517538 40.872157347... | #0660FF | 10 |
25 | POLYGON ((-73.88284445574813 40.84781722645163... | #0660FF | 12 |
26 | POLYGON ((-73.82049919995312 40.80101146781899... | #0000FF | 25 |
27 | POLYGON ((-73.84485477879177 40.7357514698091,... | #0000FF | 28 |
28 | MULTIPOLYGON (((-73.90641585511733 40.73986836... | #0440FF | 24 |
29 | POLYGON ((-73.90647314610101 40.79018117520807... | #0000FF | 30 |
30 | POLYGON ((-73.96184657346174 40.62757081710622... | #0440FF | 21 |
31 | MULTIPOLYGON (((-73.91990064270161 40.59960052... | #0000FF | 22 |
32 | MULTIPOLYGON (((-73.78833349834532 40.83466712... | #0440FF | 11 |
len(school_map_table)
7173
%matplotlib inline
t['economic_need_index'].plot(kind='bar')
<matplotlib.axes._subplots.AxesSubplot at 0x7f0db3595b00>
sorted_school_table.to_csv('data.csv', index=False)
There is a lot you can do without signing in.
To take full advantage of our site, we recommend that you sign in.
Each user starts with 1,000 free credits.