Mapping charter schools

Authors:

  • Harshayu Girase, URAP research apprentice, Computer Science major, UC Berkeley
  • Serena Jiang, URAP research apprentice, Computer Science major, UC Berkeley
  • Jaren Haber, PhD Candidate, Sociology, UC Berkeley

In [7]:
# Import packages
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
from shapely.geometry import Point
import geopandas as gpd

In [8]:
# Define data file paths
charterfile = './charters_parsed_03-04_no-text_SMALL.csv'
districtfile = './ACS_2016_sd-merged_FULL.csv'
publicfile = './pub_merged_2015_acs.csv'
shapefile = 'district.shp'

district = gpd.read_file(shapefile) # Create shapefile DF with only geometric data (for general use)

Define helper functions


In [16]:
def refresh_data():
    '''Loads data from file, undoing any bounding boxes, etc. 
    Great for making a fresh start when plotting a new area.
    
    Also merges geometric data from shapefile DF into full school district DF.
    To do this, first creates a common identifier across these DFs by modifying district 'Qualifying Name' 
    so it lines up with the district shapefile.'''
    
    global charterDF, district_df, publicDF
    
    # Import data:
    charterDF = pd.read_csv(charterfile, low_memory=False) # Charter school data
    publicDF = pd.read_csv(publicfile, low_memory=False) # Public school data
    districtDF = pd.read_csv(districtfile, encoding='latin-1', low_memory=False) # School district data
    
    # Merge shapefile with district file:
    districtDF['NAME'] = districtDF['Qualifying Name'].apply(lambda x: ",".join(x.split(",")[:-1]).strip())
    district_df = pd.merge(districtDF, district, on="NAME") 
    district_df = gpd.GeoDataFrame(district_df)
    
    # Create geometry for charter schools:
    charterDF['geometry'] = charterDF[['LONGCODE', 'LATCODE']].apply(lambda row: Point(row["LONGCODE"], row["LATCODE"]), axis=1) # Use GeoPandas to create Point class for each school
    charterDF = gpd.GeoDataFrame(charterDF)
    charterDF.crs = {'init' :'epsg:4326'}
    charterDF = charterDF.to_crs(district.crs)

    # TO DO: Improve projection so it layers the multiple shapefiles into a single map--to get rid of blank/white spaces

In [9]:
def createBoundingBox(boundingBox):
    '''Pre-requisite function for creating maps within a bounded area or "boundingBox".
    This function accomplishes this by limiting the relevant DataFrames to only those data points
    located within the bounded area defined in the two points indicated in the function call. 
    This allows the plot() function to map the entire DF (which it is designed to do).
    
    Input is a list of four numbers: [upperleft longitude, upperleft latitude, lowerleft longitude, lowerleft latitude].
    No direct output--modifies DFs.'''
    
    global publicDF
    global charterDF
    global district_df
    
    ULLON = boundingBox[0]
    ULLAT = boundingBox[1]
    LRLON = boundingBox[2]
    LRLAT = boundingBox[3]
    
    publicDF = publicDF[publicDF['LON1516']>ULLON]
    publicDF= publicDF[publicDF['LAT1516']<ULLAT]
    publicDF = publicDF[publicDF['LON1516']<LRLON]
    publicDF = publicDF[publicDF['LAT1516']>LRLAT]
    charterDF = charterDF[charterDF['LONGCODE']>ULLON]
    charterDF = charterDF[charterDF['LATCODE']<ULLAT]
    charterDF = charterDF[charterDF['LONGCODE']<LRLON]
    charterDF = charterDF[charterDF['LATCODE']>LRLAT]

    validDistricts = "" # String of all districts within bounded area, appended one at a time
    
    # Iterate over publicDF, adding each valid district into string validDistricts:
    for index, row in publicDF.iterrows():
        try:
            validDistricts += str(int(publicDF["LEAID"][index])) + " " # Grab LEAIDs for valid districts, indexing by column and then row
        except Exception as e:
            continue

    dropList = []
    
    for index, row in district_df.iterrows():
        try:
            if ((str(int(district_df["FIPS"][index]))) not in validDistricts):
                dropList.append(index)
        except Exception as e:
            continue
            
    district_df = district_df.drop(dropList) # Drop districts not in bounding box
    
    return

In [10]:
def plot(district_col, whole=True, state="", ab=""):
    '''Maps school districts in given area as chloropleth map shaded by variable district_col, 
    showing points for schools based on latitude/longitude and ess_lean. 
    Points are shaded such that blue is lower in ess_lean and red is higher.
    
    The only required parameter is district_col, the variable/column by which to shade school districts. 
    If bounding boxes are being used, ignore the other parameters below. 
    Example function call: 
    plot('Median household income (In 2014 Inflation Adjusted Dollars')
    
    Other parameters:
    whole = whether or not to map entire country (Boolean). If False, need BOTH of the following:
    state = whether to map a particular state
    ab = single state abbreviation, e.g. FL
    
    Leaving 'whole' as False and giving a state will plot that state only;
    Leaving 'whole' as False and giving no state will plot the whole US.
    
    Note on working with these functions:
    To use the single-state functionality of this function AFTER creating a bounding box, 
    rerun the notebook in order to recreate the full dataframes.'''
    
    
    figsize = (14, 7) if whole else (10,7) # Define scale for US (if whole) or single state (if not)
    fig, ax = plt.subplots(figsize=figsize)
    tempdistrict_df = district_df # Make temporary DF for within function
    
    # If mapping just one state, define state abbreviation column name:
    if not whole:
        tempdistrict_df = tempdistrict_df[tempdistrict_df['State/U.S.-Abbreviation (USPS)'] == ab]
        
    tempdistrict_df = tempdistrict_df[[district_col, 'geometry']].dropna() # Drop if no coordinates
    tempdistrict_df[district_col] = tempdistrict_df[district_col].apply(pd.to_numeric,downcast='float') # Convert to most efficient float type
    
    # Plot layers of map:
    tempdistrict_df.plot(ax = ax, column=district_col, cmap='PiYG', linewidth=0, legend=True) # Plot shaded areas
    charterDF[whole | (charterDF['STATENAME'] == state)].plot(ax = ax, cmap="coolwarm", column="ess_lean", markersize=20, linewidth=0, legend=True) # Plot points
    # Note: cmap = shading style (e.g., PiYG = pink to green)
    
    ax.legend()
    plt.show()
    
    return

Plotting


In [17]:
refresh_data() # Load in data!

In [27]:
# Example of using mapping function:
bayArea = [-123.26482826886195, 38.66436310541212, -121.06756264386195, 37.12821658249273]
createBoundingBox(bayArea)
district_df


Out[27]:
FIPS Name of Area Qualifying Name State/U.S.-Abbreviation (USPS) Summary Level Geographic Component File Identification Logical Record Number US Region ... FUNCSTAT ALAND AWATER INTPTLAT INTPTLON GISJOIN Shape_Leng Shape_Area % Total Po geometry
1453 0600019 Dublin Unified School District, California Dublin Unified School District, California ca 970 00 ACSSF 0040098 NaN NaN ... E 35426071.0 0.0 +37.7153770 -121.9104967 G06000019 37799.106445 3.542606e+07 51.76 (POLYGON ((-2235995.2443 329544.7997999992, -2...
1454 0600020 Pleasanton Unified School District, California Pleasanton Unified School District, California ca 970 00 ACSSF 0040099 NaN NaN ... E 102460910.0 391116.0 +37.6649739 -121.8867095 G06000020 58631.121814 1.028520e+08 94.96 POLYGON ((-2229697.0096 327679.7281999998, -22...
1455 0600021 Sunol Glen Unified School District, California Sunol Glen Unified School District, California ca 970 00 ACSSF 0040100 NaN NaN ... E 244322988.0 2809642.0 +37.5511338 -121.8054596 G06000021 76479.473027 2.471326e+08 80.49 POLYGON ((-2228584.443600001 317234.8045000006...
1465 0600034 Windsor Unified School District, California Windsor Unified School District, California ca 970 00 ACSSF 0040110 NaN NaN ... E 79504355.0 477276.0 +38.5491930 -122.8050545 G06000034 52828.730908 7.998163e+07 76.75 POLYGON ((-2280226.1634 445700.2112000007, -22...
1467 0600036 Natomas Unified School District, California Natomas Unified School District, California ca 970 00 ACSSF 0040112 NaN NaN ... E 95948245.0 2823304.0 +38.6670737 -121.5671691 G06000036 54828.306707 9.877155e+07 45.17 POLYGON ((-2175513.788799999 428829.7045000009...
1474 0600044 Healdsburg Unified School District, California Healdsburg Unified School District, California ca 970 00 ACSSF 0040119 NaN NaN ... E 145770119.0 345713.0 +38.6373850 -122.8884599 G06000044 78342.842100 1.461159e+08 76.54 POLYGON ((-2284174.1231 457923.0056999996, -22...
1477 0600047 Tracy Unified School District, California Tracy Unified School District, California ca 970 00 ACSSF 0040122 NaN NaN ... E 504938787.0 27600762.0 +37.8910619 -121.4707749 G06000047 163699.130232 5.316333e+08 60.11 (POLYGON ((-2194139.802200001 359195.215800000...
1497 0601332 Twin Rivers Unified School District, California Twin Rivers Unified School District, California ca 970 00 ACSSF 0040142 NaN NaN ... E 114082153.0 1389497.0 +38.6727995 -121.3842225 G06001332 89683.692314 1.154717e+08 57.54 (POLYGON ((-2167406.512 419634.0886000004, -21...
1500 0601410 Lammersville Joint Unified School District, Ca... Lammersville Joint Unified School District, Ca... ca 970 00 ACSSF 0040145 NaN NaN ... E 60842581.0 69569.0 +37.7460948 -121.5230350 G06001410 36837.286594 6.091217e+07 40.11 POLYGON ((-2201557.5886 333380.8332000002, -22...
1506 0601770 Alameda City Unified School District, California Alameda City Unified School District, California ca 970 00 ACSSF 0040152 NaN NaN ... E 27045458.0 32778370.0 +37.7419107 -122.2599139 G06001770 48864.867584 2.722580e+07 49.11 (POLYGON ((-2262129.186799999 342248.051699999...
1507 0601860 Albany City Unified School District, California Albany City Unified School District, California ca 970 00 ACSSF 0040153 NaN NaN ... E 4634305.0 9523833.0 +37.8906499 -122.3181164 G06001860 13831.201615 4.634308e+06 54.15 POLYGON ((-2260526.694399999 359333.9395000003...
1513 0602850 Antioch Unified School District, California Antioch Unified School District, California ca 970 00 ACSSF 0040159 NaN NaN ... E 102869243.0 6284270.0 +37.9789846 -121.8066181 G06002850 53937.631124 1.033205e+08 51.51 (POLYGON ((-2219432.0165 362455.9824999999, -2...
1525 0604620 Benicia Unified School District, California Benicia Unified School District, California ca 970 00 ACSSF 0040171 NaN NaN ... E 81871389.0 12200035.0 +38.0927119 -122.1381052 G06004620 50644.264077 8.361643e+07 73.08 POLYGON ((-2235598.247099999 378198.1832999997...
1526 0604740 Berkeley Unified School District, California Berkeley Unified School District, California ca 970 00 ACSSF 0040172 NaN NaN ... E 27095285.0 18715614.0 +37.8669717 -122.2991474 G06004740 37391.075458 2.732964e+07 62.24 POLYGON ((-2258010.686899999 358417.7525999993...
1537 0606780 Cabrillo Unified School District, California Cabrillo Unified School District, California ca 970 00 ACSSF 0040183 NaN NaN ... E 277459851.0 196251016.0 +37.4377371 -122.4368377 G06006780 110056.297649 2.776186e+08 80.89 POLYGON ((-2277055.568700001 301214.8978000004...
1541 0607020 Calistoga Joint Unified School District, Calif... Calistoga Joint Unified School District, Calif... ca 970 00 ACSSF 0040187 NaN NaN ... E 242823823.0 396255.0 +38.6348225 -122.6150507 G06007020 109581.438271 2.432201e+08 80.71 (POLYGON ((-2256486.6798 433436.3269999996, -2...
1546 0607800 Castro Valley Unified School District, California Castro Valley Unified School District, California ca 970 00 ACSSF 0040192 NaN NaN ... E 177385526.0 4276387.0 +37.7196716 -122.0463454 G06007800 99453.037266 1.816619e+08 58.48 POLYGON ((-2244880.855900001 343345.3857000005...
1565 0609940 Cotati-Rohnert Park Unified School District, C... Cotati-Rohnert Park Unified School District, C... ca 970 00 ACSSF 0040212 NaN NaN ... E 38554954.0 29015.0 +38.3392564 -122.7071204 G06009940 32248.759395 3.858397e+07 76.78 POLYGON ((-2283951.274599999 419968.1092000008...
1569 0610620 Davis Joint Unified School District, California Davis Joint Unified School District, California ca 970 00 ACSSF 0040216 NaN NaN ... E 329809654.0 5212509.0 +38.4946474 -121.6771343 G06010620 112930.981131 3.350222e+08 62.37 POLYGON ((-2183894.052100001 418404.6523000002...
1575 0611280 Dixon Unified School District, California Dixon Unified School District, California ca 970 00 ACSSF 0040222 NaN NaN ... E 504174328.0 7543649.0 +38.4018724 -121.7952918 G06011280 125618.635168 5.117180e+08 73.29 POLYGON ((-2205567.675799999 418361.6373999994...
1582 0612330 Elk Grove Unified School District, California Elk Grove Unified School District, California ca 970 00 ACSSF 0040229 NaN NaN ... E 850256773.0 5006014.0 +38.4413328 -121.2711972 G06012330 174034.966877 8.552628e+08 43.57 POLYGON ((-2159231.722100001 405776.9113999996...
1583 0612630 Emery Unified School District, California Emery Unified School District, California ca 970 00 ACSSF 0040230 NaN NaN ... E 3317306.0 2517858.0 +37.8399065 -122.2989635 G06012630 13553.413098 3.317306e+06 47.87 POLYGON ((-2262169.084899999 354126.2006999999...
1584 0612840 Escalon Unified School District, California Escalon Unified School District, California ca 970 00 ACSSF 0040231 NaN NaN ... E 415748799.0 1652933.0 +37.8855347 -121.0241489 G06012840 115267.911061 4.174018e+08 85.58 POLYGON ((-2142865.9977 340620.7356000002, -21...
1586 0613360 Fairfield-Suisun Unified School District, Cali... Fairfield-Suisun Unified School District, Cali... ca 970 00 ACSSF 0040233 NaN NaN ... E 612885955.0 112865467.0 +38.2073034 -122.0296674 G06013360 286911.534891 6.390225e+08 44.81 (POLYGON ((-2225191.3532 367111.4077000003, -2...
1589 0613890 Folsom-Cordova Unified School District, Califo... Folsom-Cordova Unified School District, Califo... ca 970 00 ACSSF 0040237 NaN NaN ... E 232114483.0 7314809.0 +38.6174796 -121.1845995 G06013890 96320.825096 2.394293e+08 67.38 POLYGON ((-2140512.8462 420640.3264000006, -21...
1593 0614400 Fremont Unified School District, California Fremont Unified School District, California ca 970 00 ACSSF 0040241 NaN NaN ... E 200405413.0 26291597.0 +37.4944613 -121.9411499 G06014400 137552.191538 2.006818e+08 29.27 (POLYGON ((-2247215.330800001 305414.314999999...
1603 0616740 Hayward Unified School District, California Hayward Unified School District, California ca 970 00 ACSSF 0040251 NaN NaN ... E 83902804.0 20824381.0 +37.6379509 -122.1010098 G06016740 56386.117393 8.396272e+07 42.15 POLYGON ((-2245737.1281 324064.0536000002, -22...
1609 0618990 John Swett Unified School District, California John Swett Unified School District, California ca 970 00 ACSSF 0040257 NaN NaN ... E 52776336.0 8760242.0 +38.0320857 -122.2234423 G06018990 42300.612072 5.277634e+07 55.98 POLYGON ((-2245820.6942 369833.1572999991, -22...
1617 0620220 La Honda-Pescadero Unified School District, Ca... La Honda-Pescadero Unified School District, Ca... ca 970 00 ACSSF 0040265 NaN NaN ... E 352397840.0 195033469.0 +37.2256503 -122.2975334 G06020220 119593.710327 3.533843e+08 90.43 (POLYGON ((-2289032.217700001 275493.748500000...
1623 0621690 Lincoln Unified School District, California Lincoln Unified School District, California ca 970 00 ACSSF 0040271 NaN NaN ... E 29824854.0 2402345.0 +37.9995651 -121.3622008 G06021690 44006.960627 3.222720e+07 97.58 (POLYGON ((-2174226.4231 347029.7091000006, -2...
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
1664 0627060 Newark Unified School District, California Newark Unified School District, California ca 970 00 ACSSF 0040313 NaN NaN ... E 36116580.0 60526.0 +37.5045144 -122.0329158 G06027060 30985.325892 3.617711e+07 37.89 POLYGON ((-2248367.9991 313422.1482999995, -22...
1665 0627200 Newman-Crows Landing Unified School District, ... Newman-Crows Landing Unified School District, ... ca 970 00 ACSSF 0040314 NaN NaN ... E 961651398.0 1462584.0 +37.3260075 -121.1936646 G06027200 161474.872686 9.631140e+08 84.9 POLYGON ((-2168452.7107 281652.1085999999, -21...
1669 0627720 Novato Unified School District, California Novato Unified School District, California ca 970 00 ACSSF 0040318 NaN NaN ... E 154169421.0 65184752.0 +38.0982704 -122.5403661 G06027720 71772.288599 1.558529e+08 79.43 POLYGON ((-2281656.340299999 398281.0997000001...
1671 0628050 Oakland Unified School District, California Oakland Unified School District, California ca 970 00 ACSSF 0040320 NaN NaN ... E 144803266.0 56897826.0 +37.7698464 -122.2256900 G06028050 126079.775686 1.456602e+08 39.72 (POLYGON ((-2258316.627699999 337234.1908, -22...
1679 0629610 Palo Alto Unified School District, California Palo Alto Unified School District, California ca 970 00 ACSSF 0040328 NaN NaN ... E 71013950.0 1786844.0 +37.4095181 -122.1493751 G06029610 59499.824439 7.138010e+07 61.94 (POLYGON ((-2257591.7948 306527.7954999991, -2...
1686 0630030 Patterson Joint Unified School District, Calif... Patterson Joint Unified School District, Calif... ca 970 00 ACSSF 0040335 NaN NaN ... E 931831220.0 2631591.0 +37.4975520 -121.3425653 G06030030 214476.096230 9.344629e+08 73.62 POLYGON ((-2175743.5601 301724.6655000001, -21...
1687 0630330 Piedmont City Unified School District, California Piedmont City Unified School District, California ca 970 00 ACSSF 0040336 NaN NaN ... E 4402167.0 0.0 +37.8225436 -122.2300249 G06030330 9644.820643 4.402171e+06 74.32 POLYGON ((-2258972.5386 350894.2634999994, -22...
1689 0630600 Pittsburg Unified School District, California Pittsburg Unified School District, California ca 970 00 ACSSF 0040338 NaN NaN ... E 67791737.0 8667646.0 +38.0027878 -121.8893695 G06030600 66739.280951 6.779526e+07 90.12 (POLYGON ((-2220386.3455 365440.4097000007, -2...
1700 0632550 West Contra Costa Unified School District, Cal... West Contra Costa Unified School District, Cal... ca 970 00 ACSSF 0040349 NaN NaN ... E 159621863.0 115378750.0 +37.9730280 -122.3310035 G06032550 109043.247032 1.618293e+08 46.72 (POLYGON ((-2267757.8233 361454.8627000004, -2...
1702 0632880 Ripon Unified School District, California Ripon Unified School District, California ca 970 00 ACSSF 0040351 NaN NaN ... E 139638884.0 1162294.0 +37.7788996 -121.1341904 G06032880 94823.087143 1.408012e+08 88.61 POLYGON ((-2157816.653000001 314383.0259000007...
1703 0633110 River Delta Joint Unified School District, Cal... River Delta Joint Unified School District, Cal... ca 970 00 ACSSF 0040352 NaN NaN ... E 879207201.0 74053138.0 +38.2150530 -121.6757975 G06033110 325021.815215 9.072881e+08 75.98 (POLYGON ((-2215124.4882 361054.0697000008, -2...
1707 0633840 Sacramento City Unified School District, Calif... Sacramento City Unified School District, Calif... ca 970 00 ACSSF 0040356 NaN NaN ... E 175217555.0 4937983.0 +38.5266112 -121.4544188 G06033840 100276.675892 1.801556e+08 56.47 POLYGON ((-2167132.649800001 414429.0556000005...
1711 0634410 San Francisco Unified School District, California San Francisco Unified School District, California ca 970 00 ACSSF 0040360 NaN NaN ... E 121455687.0 479136515.0 +37.7272391 -123.0322294 G06034410 155020.222734 1.232103e+08 35.2 (POLYGON ((-2272574.408399999 346623.860999999...
1714 0634590 San Jose Unified School District, California San Jose Unified School District, California ca 970 00 ACSSF 0040363 NaN NaN ... E 122648090.0 571701.0 +37.2623912 -121.8658513 G06034590 106276.987180 1.232198e+08 58.13 POLYGON ((-2238803.293 272975.5241, -2238763.6...
1715 0634620 San Juan Unified School District, California San Juan Unified School District, California ca 970 00 ACSSF 0040364 NaN NaN ... E 196793771.0 2854505.0 +38.6486140 -121.3066981 G06034620 78775.489638 1.996483e+08 94.15 POLYGON ((-2144822.364800001 422123.5492000002...
1716 0634680 San Leandro Unified School District, California San Leandro Unified School District, California ca 970 00 ACSSF 0040365 NaN NaN ... E 30080887.0 5679338.0 +37.7069948 -122.1663168 G06034680 46282.121396 3.008090e+07 43.07 POLYGON ((-2251859.855699999 337206.9690000005...
1717 0634710 San Lorenzo Unified School District, California San Lorenzo Unified School District, California ca 970 00 ACSSF 0040366 NaN NaN ... E 28581174.0 14683602.0 +37.6671133 -122.1485865 G06034710 38199.514551 2.858116e+07 48.96 POLYGON ((-2250936.470699999 332097.3003000002...
1718 0634740 San Lorenzo Valley Unified School District, Ca... San Lorenzo Valley Unified School District, Ca... ca 970 00 ACSSF 0040367 NaN NaN ... E 235764611.0 737895.0 +37.1408751 -122.1152795 G06034740 89480.913927 2.365025e+08 92.23 POLYGON ((-2269535.7875 283998.6740000006, -22...
1723 0635130 San Ramon Valley Unified School District, Cali... San Ramon Valley Unified School District, Cali... ca 970 00 ACSSF 0040372 NaN NaN ... E 276720424.0 72161.0 +37.8046693 -121.9365298 G06035130 76644.294902 2.767926e+08 65.48 POLYGON ((-2223997.9202 342925.0000999998, -22...
1726 0635430 Santa Clara Unified School District, California Santa Clara Unified School District, California ca 970 00 ACSSF 0040375 NaN NaN ... E 105998991.0 3838063.0 +37.4016881 -121.9733927 G06035430 102138.464583 1.063069e+08 46.33 (POLYGON ((-2249350.423 289361.3359999992, -22...
1730 0636670 Shoreline Unified School District, California Shoreline Unified School District, California ca 970 00 ACSSF 0040379 NaN NaN ... E 611141401.0 436990440.0 +38.1855080 -122.9483652 G06036670 366519.191170 6.153625e+08 80 (POLYGON ((-2309325.2081 412073.8903000001, -2...
1738 0637200 Sonoma Valley Unified School District, California Sonoma Valley Unified School District, California ca 970 00 ACSSF 0040387 NaN NaN ... E 311653474.0 1994246.0 +38.2908198 -122.4703247 G06037200 103327.620563 3.136477e+08 82.71 POLYGON ((-2261741.4738 420753.6270000003, -22...
1740 0637530 South San Francisco Unified School District, C... South San Francisco Unified School District, C... ca 970 00 ACSSF 0040389 NaN NaN ... E 29539476.0 38401356.0 +37.6551037 -122.3762341 G06037530 42217.881937 2.949232e+07 35.2 (POLYGON ((-2277078.4189 333944.8653999995, -2...
1744 0637830 St. Helena Unified School District, California St. Helena Unified School District, California ca 970 00 ACSSF 0040393 NaN NaN ... E 730933164.0 81128373.0 +38.5954891 -122.3199583 G06037830 315113.356008 8.120616e+08 82.07 (POLYGON ((-2264230.603599999 437929.174399999...
1745 0638010 Stockton Unified School District, California Stockton Unified School District, California ca 970 00 ACSSF 0040394 NaN NaN ... E 146392980.0 3253362.0 +37.9553945 -121.2702579 G06038010 88190.926673 1.496464e+08 95.76 POLYGON ((-2170975.282500001 347048.5033999998...
1752 0639630 Travis Unified School District, California Travis Unified School District, California ca 970 00 ACSSF 0040402 NaN NaN ... E 114770909.0 917513.0 +38.2822211 -121.9247148 G06039630 51213.373316 1.156884e+08 53.22 POLYGON ((-2210620.5044 393778.0342999995, -22...
1757 0640590 Vacaville Unified School District, California Vacaville Unified School District, California ca 970 00 ACSSF 0040407 NaN NaN ... E 268981179.0 1084669.0 +38.3823938 -121.9873549 G06040590 95944.704518 2.700658e+08 71.32 POLYGON ((-2216439.7926 414003.5238000005, -22...
1758 0640740 Vallejo City Unified School District, California Vallejo City Unified School District, California ca 970 00 ACSSF 0040408 NaN NaN ... E 107573628.0 64975434.0 +38.1132602 -122.2815836 G06040740 101834.502318 1.100767e+08 42.33 (POLYGON ((-2251211.720699999 386572.5581, -22...
1770 0642930 Winters Joint Unified School District, California Winters Joint Unified School District, California ca 970 00 ACSSF 0040421 NaN NaN ... E 331379360.0 980301.0 +38.5688660 -122.0797813 G06042930 98552.964618 3.323597e+08 72.64 POLYGON ((-2208763.0843 430452.2940999996, -22...
1771 0643080 Woodland Joint Unified School District, Califo... Woodland Joint Unified School District, Califo... ca 970 00 ACSSF 0040422 NaN NaN ... E 799200760.0 8975161.0 +38.7201907 -121.7710472 G06043080 174546.217131 8.081760e+08 70.86 POLYGON ((-2191566.731899999 454425.6618000008...

70 rows × 172 columns


In [18]:
refresh_data() # Refresh data and undo Bay Area bounding box

# Remove outliers using ess_lean:
charterDF['ess_lean'] = charterDF['ess_strength'] - charterDF['prog_strength']
charterDF = charterDF.dropna(subset=["ess_lean"])
high = charterDF['ess_lean'].quantile(.98) # Find upper limit of ess_lean (a number)
low = charterDF['ess_lean'].quantile(.02)
charterDF = charterDF[(charterDF['ess_lean'] < high) & (charterDF['ess_lean'] > low)]

In [21]:
plot('% Total Population: White Alone', False, 'CALIFORNIA', 'ca')


/Users/harshayugirase/anaconda/lib/python3.6/site-packages/matplotlib/axes/_axes.py:545: UserWarning: No labelled objects found. Use label='...' kwarg on individual plots.
  warnings.warn("No labelled objects found. "

In [22]:
plot('% Total Population: White Alone')


/Users/harshayugirase/anaconda/lib/python3.6/site-packages/matplotlib/axes/_axes.py:545: UserWarning: No labelled objects found. Use label='...' kwarg on individual plots.
  warnings.warn("No labelled objects found. "

In [38]:
plot('% Total Population: White Alone')


/Users/harshayugirase/anaconda/lib/python3.6/site-packages/matplotlib/axes/_axes.py:545: UserWarning: No labelled objects found. Use label='...' kwarg on individual plots.
  warnings.warn("No labelled objects found. "

In [40]:
plot('Total Population: Foreign Born: Not a Citizen')


/Users/harshayugirase/anaconda/lib/python3.6/site-packages/matplotlib/axes/_axes.py:545: UserWarning: No labelled objects found. Use label='...' kwarg on individual plots.
  warnings.warn("No labelled objects found. "