Final Exam - Option 1

Census Data Analysis

Data was downloaded the data from this link: http://thedataweb.rm.census.gov/ftp/cps_ftp.html

Download the data disctionary for June 2015 and extract it in the same folder as this notebook.

I will extract the data from this dictionary for the income, education, ethnicity and state. The U.S. Census Bureau documents this data as people have self-identified for each question on a Census survey.

Then I'll display this information on a google map, displaying a visualization of the data on it's corresponding state from which it was recorded.

In [50]:
#Values to States
states_map = { 1:'AL',30:'MT',2:'AK',31:'NE',4:'AZ',32:'NV',5:'AR',33:'NH',
              6:'CA',34:'NJ',8:'CO',35:'NM',9:'CT',36:'NY',10:'DE',37:'NC',
              11:'DC',38:'ND',12:'FL',39:'OH',13:'GA',40:'OK',15:'HI',41:'OR',
              16:'ID',42:'PA',17:'IL',44:'RI',18:'IN',45:'SC',19:'IA',46:'SD',
              20:'KS',47:'TN',21:'KY',48:'TX',22:'LA',49:'UT',23:'ME',50:'VT',
              24:'MD',51:'VA',25:'MA',53:'WA',26:'MI',54:'WV',27:'MN',55:'WI',
              28:'MS',56:'WY',29:'MO' }
In [51]:
#This value and higher will be considered RICH
RICH_FLAG = 15  # $100,000 or more
#This value and higher will be considered EDUCATED
EDUCATED_FLAG = 43  # Bachelor's Degree or higher
In [52]:
#Values to Races
#for simplicity I will group basic races
WHITE = 1
BLACK = 2
NATIVE = 3  #American Indian, Alaskan Native
ASIAN = 4
ISLANDER = 5  #Hawaiian/Pacific Islander
MULTI_RACIAL = 6  #Multi-Racial >= 6 
In [53]:
#Create the lists we need to store the data we will retrieve
#from the Census data dictionary
income = []
education = []
ethnicity = []  
state = []
#to hold counts per state
state_count = {} 
#to store values 
# RICH AND EDUCATED          [W, B, AI, A, H, M
# RICH AND NON-EDUCATED
# NON-RICH AND EDUCATED 
# NON-RICH AND NON-EDUCATED 
#                                      total]
state_count_template = [0,0,0,0,0,0,
                        0,0,0,0,0,0,
                        0,0,0,0,0,0,
                        0,0,0,0,0,0,
                        0]
In [54]:
with open('jun15pub.dat') as data_file:
    for line in data_file.readlines():

        inc = int(line[38:40])
        edu = int(line[136:138])
        eth = int(line[138:140]) 
        st = states_map[int(line[92:94])]

        income.append(inc)
        education.append(edu)
        ethnicity.append(eth) 
        state.append(st)

        if st not in state_count:
            state_count[st] = state_count_template[:]

        #total count in states of all categories
        state_count[st][24] += 1

        #RICH AND EDUCATED
        if inc >= RICH_FLAG and edu >= EDUCATED_FLAG:
            if eth == WHITE:   #White Only
                state_count[st][0] += 1
            elif eth == BLACK:  #Black Only
                state_count[st][1] += 1
            elif eth == NATIVE:  #American Indian, Alaskan Native Only
                state_count[st][2] += 1
            elif eth == ASIAN:  #Asian Only
                state_count[st][3] += 1
            elif eth == ISLANDER:  #Hawaiian/Pacific Islander Only
                state_count[st][4] += 1
            else: # Multi-Racial
                state_count[st][5] += 1
        #RICH AND NON-EDUCATED
        elif inc >= RICH_FLAG and edu < EDUCATED_FLAG: 
            if eth == WHITE:
                state_count[st][6] += 1
            elif eth == BLACK:
                state_count[st][7] += 1
            elif eth == NATIVE:
                state_count[st][8] += 1
            elif eth == ASIAN:
                state_count[st][9] += 1
            elif eth == ISLANDER:
                state_count[st][10] += 1
            else: 
                state_count[st][11] += 1
        #NON-RICH AND EDUCATED
        elif inc < RICH_FLAG and edu >= EDUCATED_FLAG:
            if eth == WHITE:
                state_count[st][12] += 1
            elif eth == BLACK:
                state_count[st][13] += 1
            elif eth == NATIVE:
                state_count[st][14] += 1
            elif eth == ASIAN:
                state_count[st][15] += 1
            elif eth == ISLANDER:
                state_count[st][16] += 1
            else: 
                state_count[st][17] += 1
        #NON-RICH AND NON-EDUCATED
        else:
            if eth == WHITE:
                state_count[st][18] += 1
            elif eth == BLACK:
                state_count[st][19] += 1
            elif eth == NATIVE:
                state_count[st][20] += 1
            elif eth == ASIAN:
                state_count[st][21] += 1
            elif eth == ISLANDER:
                state_count[st][22] += 1
            else: 
                state_count[st][23] += 1
     
In [55]:
#Use these to store each group count to be displayed
#with its corresponding state

#RICH AND EDUCATED
displayAW = ""
displayAB = ""
displayAI = ""
displayAA = ""
displayAH = ""
displayAM = ""


for state in state_count:
    #store the percentage of population group of each state
    groupAW = state_count[state][0]/float(state_count[state][24])
    groupAB = state_count[state][1]/float(state_count[state][24])
    groupAI = state_count[state][2]/float(state_count[state][24])
    groupAA = state_count[state][3]/float(state_count[state][24])
    groupAH = state_count[state][4]/float(state_count[state][24])
    groupAM = state_count[state][5]/float(state_count[state][24])
    
    #store these states with group value
    #these will be used as a tooltip on our map
    displayAW += "['US-%s', %f]," % (state,groupAW)
    displayAB += "['US-%s', %f]," % (state,groupAB)
    displayAI += "['US-%s', %f]," % (state,groupAI)
    displayAA += "['US-%s', %f]," % (state,groupAA)
    displayAH += "['US-%s', %f]," % (state,groupAH)
    displayAM += "['US-%s', %f]," % (state,groupAM)

print 'RICH AND EDUCATED WHITE: '    
print displayAW
print 'RICH AND EDUCATED BLACK: '    
print displayAB
print 'RICH AND EDUCATED NATIVE: '    
print displayAI
print 'RICH AND EDUCATED ASIAN: '    
print displayAA
print 'RICH AND EDUCATED ISLANDER: '    
print displayAH
print 'RICH AND EDUCATED MULTI: '    
print displayAM
RICH AND EDUCATED WHITE: 
['US-WA', 0.079305],['US-DE', 0.061598],['US-DC', 0.180545],['US-WI', 0.061496],['US-WV', 0.043390],['US-HI', 0.029602],['US-FL', 0.056660],['US-WY', 0.060202],['US-NH', 0.102284],['US-NJ', 0.117347],['US-NM', 0.042931],['US-TX', 0.067005],['US-LA', 0.046653],['US-NC', 0.052524],['US-ND', 0.060566],['US-NE', 0.058824],['US-TN', 0.053187],['US-NY', 0.089620],['US-PA', 0.083216],['US-CA', 0.079164],['US-NV', 0.049779],['US-VA', 0.115425],['US-CO', 0.104258],['US-AK', 0.064690],['US-AL', 0.036573],['US-AR', 0.047582],['US-VT', 0.087892],['US-IL', 0.102294],['US-GA', 0.041045],['US-IN', 0.065256],['US-IA', 0.069877],['US-OK', 0.039199],['US-AZ', 0.063705],['US-ID', 0.046457],['US-CT', 0.139755],['US-ME', 0.064861],['US-MD', 0.115734],['US-MA', 0.141243],['US-OH', 0.067410],['US-UT', 0.065114],['US-MO', 0.067971],['US-MN', 0.073522],['US-MI', 0.061341],['US-RI', 0.100126],['US-KS', 0.092233],['US-MT', 0.052387],['US-MS', 0.026998],['US-SC', 0.070473],['US-KY', 0.056444],['US-OR', 0.082814],['US-SD', 0.058824],
RICH AND EDUCATED BLACK: 
['US-WA', 0.004532],['US-DE', 0.003330],['US-DC', 0.025292],['US-WI', 0.001377],['US-WV', 0.000289],['US-HI', 0.000463],['US-FL', 0.004735],['US-WY', 0.000000],['US-NH', 0.001427],['US-NJ', 0.009247],['US-NM', 0.002221],['US-TX', 0.004365],['US-LA', 0.006362],['US-NC', 0.008170],['US-ND', 0.000436],['US-NE', 0.001089],['US-TN', 0.004149],['US-NY', 0.006844],['US-PA', 0.003282],['US-CA', 0.004444],['US-NV', 0.002765],['US-VA', 0.009178],['US-CO', 0.000979],['US-AK', 0.002156],['US-AL', 0.004064],['US-AR', 0.003095],['US-VT', 0.000000],['US-IL', 0.005618],['US-GA', 0.012438],['US-IN', 0.001764],['US-IA', 0.001174],['US-OK', 0.002556],['US-AZ', 0.002096],['US-ID', 0.000000],['US-CT', 0.001114],['US-ME', 0.001889],['US-MD', 0.029173],['US-MA', 0.004590],['US-OH', 0.004213],['US-UT', 0.000431],['US-MO', 0.002445],['US-MN', 0.001922],['US-MI', 0.002992],['US-RI', 0.001889],['US-KS', 0.000000],['US-MT', 0.000332],['US-MS', 0.006750],['US-SC', 0.006244],['US-KY', 0.000000],['US-OR', 0.000445],['US-SD', 0.000000],
RICH AND EDUCATED NATIVE: 
['US-WA', 0.000755],['US-DE', 0.000555],['US-DC', 0.001556],['US-WI', 0.000000],['US-WV', 0.000000],['US-HI', 0.000000],['US-FL', 0.000158],['US-WY', 0.000000],['US-NH', 0.000476],['US-NJ', 0.000319],['US-NM', 0.001480],['US-TX', 0.000472],['US-LA', 0.000000],['US-NC', 0.000584],['US-ND', 0.000871],['US-NE', 0.000000],['US-TN', 0.000000],['US-NY', 0.000000],['US-PA', 0.000000],['US-CA', 0.000165],['US-NV', 0.000553],['US-VA', 0.000000],['US-CO', 0.000000],['US-AK', 0.000000],['US-AL', 0.001016],['US-AR', 0.000387],['US-VT', 0.000000],['US-IL', 0.000234],['US-GA', 0.000000],['US-IN', 0.000000],['US-IA', 0.000000],['US-OK', 0.005113],['US-AZ', 0.000000],['US-ID', 0.000469],['US-CT', 0.000000],['US-ME', 0.000000],['US-MD', 0.000956],['US-MA', 0.000000],['US-OH', 0.000000],['US-UT', 0.000431],['US-MO', 0.000000],['US-MN', 0.000481],['US-MI', 0.000000],['US-RI', 0.000000],['US-KS', 0.000000],['US-MT', 0.000332],['US-MS', 0.000000],['US-SC', 0.000892],['US-KY', 0.000000],['US-OR', 0.000000],['US-SD', 0.001188],
RICH AND EDUCATED ASIAN: 
['US-WA', 0.016239],['US-DE', 0.006659],['US-DC', 0.012451],['US-WI', 0.000918],['US-WV', 0.000868],['US-HI', 0.038390],['US-FL', 0.002841],['US-WY', 0.000919],['US-NH', 0.006660],['US-NJ', 0.027742],['US-NM', 0.002961],['US-TX', 0.007314],['US-LA', 0.003029],['US-NC', 0.002626],['US-ND', 0.001307],['US-NE', 0.000000],['US-TN', 0.001509],['US-NY', 0.010917],['US-PA', 0.006798],['US-CA', 0.023782],['US-NV', 0.003319],['US-VA', 0.016237],['US-CO', 0.006853],['US-AK', 0.002695],['US-AL', 0.000339],['US-AR', 0.002321],['US-VT', 0.000448],['US-IL', 0.013109],['US-GA', 0.003731],['US-IN', 0.000882],['US-IA', 0.005285],['US-OK', 0.004261],['US-AZ', 0.002515],['US-ID', 0.000000],['US-CT', 0.006682],['US-ME', 0.000630],['US-MD', 0.011478],['US-MA', 0.008828],['US-OH', 0.002230],['US-UT', 0.001725],['US-MO', 0.004890],['US-MN', 0.007689],['US-MI', 0.002095],['US-RI', 0.003778],['US-KS', 0.002157],['US-MT', 0.000663],['US-MS', 0.000710],['US-SC', 0.003122],['US-KY', 0.000000],['US-OR', 0.005343],['US-SD', 0.001188],
RICH AND EDUCATED ISLANDER: 
['US-WA', 0.000000],['US-DE', 0.000000],['US-DC', 0.000389],['US-WI', 0.000000],['US-WV', 0.000000],['US-HI', 0.003700],['US-FL', 0.000000],['US-WY', 0.000460],['US-NH', 0.000000],['US-NJ', 0.000000],['US-NM', 0.000000],['US-TX', 0.000118],['US-LA', 0.000303],['US-NC', 0.000000],['US-ND', 0.000000],['US-NE', 0.000000],['US-TN', 0.000000],['US-NY', 0.000163],['US-PA', 0.000000],['US-CA', 0.000165],['US-NV', 0.001659],['US-VA', 0.000353],['US-CO', 0.000000],['US-AK', 0.001078],['US-AL', 0.000000],['US-AR', 0.000000],['US-VT', 0.000000],['US-IL', 0.000000],['US-GA', 0.000000],['US-IN', 0.000000],['US-IA', 0.000000],['US-OK', 0.000000],['US-AZ', 0.000000],['US-ID', 0.000000],['US-CT', 0.000000],['US-ME', 0.000000],['US-MD', 0.000000],['US-MA', 0.000000],['US-OH', 0.000000],['US-UT', 0.000000],['US-MO', 0.000000],['US-MN', 0.000000],['US-MI', 0.000000],['US-RI', 0.000000],['US-KS', 0.000000],['US-MT', 0.000000],['US-MS', 0.000000],['US-SC', 0.000000],['US-KY', 0.000000],['US-OR', 0.000000],['US-SD', 0.000000],
RICH AND EDUCATED MULTI: 
['US-WA', 0.003776],['US-DE', 0.000000],['US-DC', 0.003891],['US-WI', 0.000459],['US-WV', 0.000579],['US-HI', 0.007401],['US-FL', 0.000789],['US-WY', 0.000460],['US-NH', 0.000951],['US-NJ', 0.000638],['US-NM', 0.000740],['US-TX', 0.000590],['US-LA', 0.000909],['US-NC', 0.000292],['US-ND', 0.000000],['US-NE', 0.000545],['US-TN', 0.000377],['US-NY', 0.000978],['US-PA', 0.001172],['US-CA', 0.002304],['US-NV', 0.000000],['US-VA', 0.001412],['US-CO', 0.000489],['US-AK', 0.004313],['US-AL', 0.000000],['US-AR', 0.000000],['US-VT', 0.000448],['US-IL', 0.001404],['US-GA', 0.000311],['US-IN', 0.000000],['US-IA', 0.000587],['US-OK', 0.002130],['US-AZ', 0.000419],['US-ID', 0.000469],['US-CT', 0.000557],['US-ME', 0.000630],['US-MD', 0.002391],['US-MA', 0.001059],['US-OH', 0.000496],['US-UT', 0.000431],['US-MO', 0.000978],['US-MN', 0.000481],['US-MI', 0.000299],['US-RI', 0.001259],['US-KS', 0.000539],['US-MT', 0.000663],['US-MS', 0.000000],['US-SC', 0.000892],['US-KY', 0.000000],['US-OR', 0.000000],['US-SD', 0.000000],
In [56]:
#Use these to store each group count to be displayed
#with its corresponding state

#RICH AND NON-EDUCATED
displayBW = ""
displayBB = ""
displayBI = ""
displayBA = ""
displayBH = ""
displayBM = ""

for state in state_count:
    #store the percentage of population group of each state
    groupBW = state_count[state][6]/float(state_count[state][24])
    groupBB = state_count[state][7]/float(state_count[state][24])
    groupBI = state_count[state][8]/float(state_count[state][24])
    groupBA = state_count[state][9]/float(state_count[state][24])
    groupBH = state_count[state][10]/float(state_count[state][24])
    groupBM = state_count[state][11]/float(state_count[state][24])
    
    #store these states with group value
    #these will be used as a tooltip on our map
    displayBW += "['US-%s', %f]," % (state,groupBW)
    displayBB += "['US-%s', %f]," % (state,groupBB)
    displayBI += "['US-%s', %f]," % (state,groupBI)
    displayBA += "['US-%s', %f]," % (state,groupBA)
    displayBH += "['US-%s', %f]," % (state,groupBH)
    displayBM += "['US-%s', %f]," % (state,groupBM)

print 'RICH AND NON-EDUCATED WHITE: '    
print displayBW
print 'RICH AND NON-EDUCATED BLACK: '    
print displayBB
print 'RICH AND NON-EDUCATED NATIVE: '    
print displayBI
print 'RICH AND NON-EDUCATED ASIAN: '    
print displayBA
print 'RICH AND NON-EDUCATED ISLANDER: '    
print displayBH
print 'RICH AND NON-EDUCATED MULTI: '    
print displayBM
RICH AND NON-EDUCATED WHITE: 
['US-WA', 0.120091],['US-DE', 0.084351],['US-DC', 0.047082],['US-WI', 0.094539],['US-WV', 0.076656],['US-HI', 0.028215],['US-FL', 0.068971],['US-WY', 0.153493],['US-NH', 0.146527],['US-NJ', 0.131696],['US-NM', 0.062176],['US-TX', 0.104164],['US-LA', 0.088155],['US-NC', 0.063612],['US-ND', 0.132898],['US-NE', 0.129085],['US-TN', 0.067522],['US-NY', 0.091250],['US-PA', 0.111111],['US-CA', 0.103028],['US-NV', 0.087389],['US-VA', 0.126015],['US-CO', 0.123837],['US-AK', 0.124528],['US-AL', 0.074162],['US-AR', 0.076983],['US-VT', 0.089238],['US-IL', 0.138109],['US-GA', 0.058147],['US-IN', 0.097443],['US-IA', 0.085731],['US-OK', 0.086919],['US-AZ', 0.092624],['US-ID', 0.105584],['US-CT', 0.174276],['US-ME', 0.084383],['US-MD', 0.115734],['US-MA', 0.131356],['US-OH', 0.086245],['US-UT', 0.153083],['US-MO', 0.084108],['US-MN', 0.150408],['US-MI', 0.084979],['US-RI', 0.113350],['US-KS', 0.092233],['US-MT', 0.093833],['US-MS', 0.053996],['US-SC', 0.073149],['US-KY', 0.074925],['US-OR', 0.114871],['US-SD', 0.101010],
RICH AND NON-EDUCATED BLACK: 
['US-WA', 0.006420],['US-DE', 0.011099],['US-DC', 0.013230],['US-WI', 0.004130],['US-WV', 0.001446],['US-HI', 0.001388],['US-FL', 0.004735],['US-WY', 0.000919],['US-NH', 0.000476],['US-NJ', 0.016582],['US-NM', 0.001110],['US-TX', 0.009201],['US-LA', 0.018782],['US-NC', 0.009921],['US-ND', 0.000000],['US-NE', 0.000545],['US-TN', 0.003395],['US-NY', 0.013036],['US-PA', 0.008439],['US-CA', 0.004115],['US-NV', 0.009956],['US-VA', 0.019767],['US-CO', 0.002447],['US-AK', 0.001617],['US-AL', 0.016593],['US-AR', 0.008124],['US-VT', 0.000448],['US-IL', 0.008895],['US-GA', 0.017724],['US-IN', 0.003527],['US-IA', 0.002349],['US-OK', 0.003409],['US-AZ', 0.001676],['US-ID', 0.000469],['US-CT', 0.006125],['US-ME', 0.002519],['US-MD', 0.036346],['US-MA', 0.009181],['US-OH', 0.004957],['US-UT', 0.002587],['US-MO', 0.007824],['US-MN', 0.000961],['US-MI', 0.005685],['US-RI', 0.000630],['US-KS', 0.000539],['US-MT', 0.001658],['US-MS', 0.013144],['US-SC', 0.008921],['US-KY', 0.001998],['US-OR', 0.001781],['US-SD', 0.002377],
RICH AND NON-EDUCATED NATIVE: 
['US-WA', 0.000378],['US-DE', 0.000000],['US-DC', 0.001946],['US-WI', 0.000000],['US-WV', 0.000000],['US-HI', 0.000000],['US-FL', 0.000473],['US-WY', 0.000000],['US-NH', 0.000000],['US-NJ', 0.000638],['US-NM', 0.002591],['US-TX', 0.000118],['US-LA', 0.000000],['US-NC', 0.000000],['US-ND', 0.003922],['US-NE', 0.001089],['US-TN', 0.000000],['US-NY', 0.000163],['US-PA', 0.000000],['US-CA', 0.000494],['US-NV', 0.001659],['US-VA', 0.000353],['US-CO', 0.000000],['US-AK', 0.012938],['US-AL', 0.001016],['US-AR', 0.001161],['US-VT', 0.000448],['US-IL', 0.000000],['US-GA', 0.000000],['US-IN', 0.000000],['US-IA', 0.000000],['US-OK', 0.007669],['US-AZ', 0.001257],['US-ID', 0.000000],['US-CT', 0.000000],['US-ME', 0.000000],['US-MD', 0.000478],['US-MA', 0.000000],['US-OH', 0.000000],['US-UT', 0.001294],['US-MO', 0.000000],['US-MN', 0.000000],['US-MI', 0.001496],['US-RI', 0.000000],['US-KS', 0.001079],['US-MT', 0.004310],['US-MS', 0.000355],['US-SC', 0.000000],['US-KY', 0.000000],['US-OR', 0.001781],['US-SD', 0.003565],
RICH AND NON-EDUCATED ASIAN: 
['US-WA', 0.012840],['US-DE', 0.006104],['US-DC', 0.002724],['US-WI', 0.002295],['US-WV', 0.000000],['US-HI', 0.080019],['US-FL', 0.002525],['US-WY', 0.000460],['US-NH', 0.006660],['US-NJ', 0.016901],['US-NM', 0.004811],['US-TX', 0.006252],['US-LA', 0.001818],['US-NC', 0.003502],['US-ND', 0.001307],['US-NE', 0.000545],['US-TN', 0.001509],['US-NY', 0.006681],['US-PA', 0.004219],['US-CA', 0.025346],['US-NV', 0.003872],['US-VA', 0.012001],['US-CO', 0.005384],['US-AK', 0.005930],['US-AL', 0.002709],['US-AR', 0.001547],['US-VT', 0.000897],['US-IL', 0.013109],['US-GA', 0.001866],['US-IN', 0.000882],['US-IA', 0.002936],['US-OK', 0.003835],['US-AZ', 0.002096],['US-ID', 0.000469],['US-CT', 0.002227],['US-ME', 0.000000],['US-MD', 0.005261],['US-MA', 0.006356],['US-OH', 0.002726],['US-UT', 0.001294],['US-MO', 0.001956],['US-MN', 0.006728],['US-MI', 0.002095],['US-RI', 0.001889],['US-KS', 0.010248],['US-MT', 0.000000],['US-MS', 0.000710],['US-SC', 0.001338],['US-KY', 0.000999],['US-OR', 0.009350],['US-SD', 0.000594],
RICH AND NON-EDUCATED ISLANDER: 
['US-WA', 0.001511],['US-DE', 0.000000],['US-DC', 0.000000],['US-WI', 0.000000],['US-WV', 0.000000],['US-HI', 0.012026],['US-FL', 0.000000],['US-WY', 0.000000],['US-NH', 0.000476],['US-NJ', 0.000000],['US-NM', 0.000000],['US-TX', 0.000000],['US-LA', 0.000000],['US-NC', 0.000000],['US-ND', 0.000000],['US-NE', 0.000545],['US-TN', 0.000000],['US-NY', 0.000000],['US-PA', 0.000000],['US-CA', 0.001317],['US-NV', 0.002212],['US-VA', 0.000000],['US-CO', 0.000000],['US-AK', 0.001617],['US-AL', 0.000000],['US-AR', 0.000000],['US-VT', 0.000000],['US-IL', 0.000234],['US-GA', 0.000000],['US-IN', 0.000000],['US-IA', 0.000000],['US-OK', 0.000000],['US-AZ', 0.000000],['US-ID', 0.000000],['US-CT', 0.000000],['US-ME', 0.000000],['US-MD', 0.000000],['US-MA', 0.000000],['US-OH', 0.000248],['US-UT', 0.000000],['US-MO', 0.000000],['US-MN', 0.000000],['US-MI', 0.000000],['US-RI', 0.000000],['US-KS', 0.000000],['US-MT', 0.000000],['US-MS', 0.000000],['US-SC', 0.000000],['US-KY', 0.000000],['US-OR', 0.000000],['US-SD', 0.000000],
RICH AND NON-EDUCATED MULTI: 
['US-WA', 0.009441],['US-DE', 0.001110],['US-DC', 0.002335],['US-WI', 0.002754],['US-WV', 0.000579],['US-HI', 0.029140],['US-FL', 0.002052],['US-WY', 0.003217],['US-NH', 0.003330],['US-NJ', 0.001913],['US-NM', 0.002961],['US-TX', 0.002949],['US-LA', 0.002121],['US-NC', 0.002918],['US-ND', 0.001743],['US-NE', 0.002179],['US-TN', 0.003772],['US-NY', 0.006355],['US-PA', 0.001875],['US-CA', 0.006254],['US-NV', 0.003319],['US-VA', 0.004236],['US-CO', 0.006853],['US-AK', 0.014016],['US-AL', 0.000000],['US-AR', 0.000000],['US-VT', 0.000897],['US-IL', 0.002107],['US-GA', 0.001244],['US-IN', 0.000000],['US-IA', 0.001174],['US-OK', 0.002130],['US-AZ', 0.002515],['US-ID', 0.000939],['US-CT', 0.002227],['US-ME', 0.000630],['US-MD', 0.013869],['US-MA', 0.001412],['US-OH', 0.003470],['US-UT', 0.004312],['US-MO', 0.004401],['US-MN', 0.002403],['US-MI', 0.003890],['US-RI', 0.000000],['US-KS', 0.001618],['US-MT', 0.002653],['US-MS', 0.000355],['US-SC', 0.000446],['US-KY', 0.000500],['US-OR', 0.006233],['US-SD', 0.000000],
In [57]:
#Use these to store each group count to be displayed
#with its corresponding state

#NON-RICH AND EDUCATED
displayCW = ""
displayCB = ""
displayCI = ""
displayCA = ""
displayCH = ""
displayCM = ""

for state in state_count:
    #store the percentage of population group of each state
    groupCW = state_count[state][12]/float(state_count[state][24])
    groupCB = state_count[state][13]/float(state_count[state][24])
    groupCI = state_count[state][14]/float(state_count[state][24])
    groupCA = state_count[state][15]/float(state_count[state][24])
    groupCH = state_count[state][16]/float(state_count[state][24])
    groupCM = state_count[state][17]/float(state_count[state][24])
    
    #store these states with group value
    #these will be used as a tooltip on our map
    displayCW += "['US-%s', %f]," % (state,groupCW)
    displayCB += "['US-%s', %f]," % (state,groupCB)
    displayCI += "['US-%s', %f]," % (state,groupCI)
    displayCA += "['US-%s', %f]," % (state,groupCA)
    displayCH += "['US-%s', %f]," % (state,groupCH)
    displayCM += "['US-%s', %f]," % (state,groupCM)

print 'NON-RICH AND EDUCATED WHITE: '    
print displayCW
print 'NON-RICH AND EDUCATED BLACK: '    
print displayCB
print 'NON-RICH AND EDUCATED NATIVE: '    
print displayCI
print 'NON-RICH AND EDUCATED ASIAN: '    
print displayCA
print 'NON-RICH AND EDUCATED ISLANDER: '    
print displayCH
print 'NON-RICH AND EDUCATED MULTI: '    
print displayCM
NON-RICH AND EDUCATED WHITE: 
['US-WA', 0.103097],['US-DE', 0.102664],['US-DC', 0.091051],['US-WI', 0.117026],['US-WV', 0.081574],['US-HI', 0.043478],['US-FL', 0.099116],['US-WY', 0.095588],['US-NH', 0.109895],['US-NJ', 0.091199],['US-NM', 0.093264],['US-TX', 0.071252],['US-LA', 0.062708],['US-NC', 0.098629],['US-ND', 0.104139],['US-NE', 0.106209],['US-TN', 0.097322],['US-NY', 0.089946],['US-PA', 0.104079],['US-CA', 0.077930],['US-NV', 0.082965],['US-VA', 0.080833],['US-CO', 0.137053],['US-AK', 0.069542],['US-AL', 0.077887],['US-AR', 0.075822],['US-VT', 0.153812],['US-IL', 0.101826],['US-GA', 0.079913],['US-IN', 0.095679],['US-IA', 0.095713],['US-OK', 0.074137],['US-AZ', 0.092624],['US-ID', 0.122008],['US-CT', 0.099666],['US-ME', 0.105793],['US-MD', 0.055476],['US-MA', 0.100636],['US-OH', 0.097893],['US-UT', 0.105649],['US-MO', 0.112469],['US-MN', 0.112446],['US-MI', 0.090365],['US-RI', 0.120907],['US-KS', 0.101402],['US-MT', 0.137268],['US-MS', 0.064298],['US-SC', 0.079393],['US-KY', 0.084416],['US-OR', 0.123330],['US-SD', 0.115270],
NON-RICH AND EDUCATED BLACK: 
['US-WA', 0.003021],['US-DE', 0.013873],['US-DC', 0.044747],['US-WI', 0.000918],['US-WV', 0.002314],['US-HI', 0.003238],['US-FL', 0.015625],['US-WY', 0.000460],['US-NH', 0.000476],['US-NJ', 0.013074],['US-NM', 0.003701],['US-TX', 0.011797],['US-LA', 0.020903],['US-NC', 0.021885],['US-ND', 0.002179],['US-NE', 0.004902],['US-TN', 0.012071],['US-NY', 0.012058],['US-PA', 0.011017],['US-CA', 0.006007],['US-NV', 0.008850],['US-VA', 0.017296],['US-CO', 0.008321],['US-AK', 0.003235],['US-AL', 0.018964],['US-AR', 0.011992],['US-VT', 0.000000],['US-IL', 0.011236],['US-GA', 0.034204],['US-IN', 0.009700],['US-IA', 0.002349],['US-OK', 0.004261],['US-AZ', 0.005029],['US-ID', 0.001408],['US-CT', 0.006682],['US-ME', 0.000000],['US-MD', 0.029651],['US-MA', 0.001766],['US-OH', 0.007187],['US-UT', 0.000431],['US-MO', 0.008802],['US-MN', 0.003844],['US-MI', 0.009874],['US-RI', 0.005038],['US-KS', 0.004315],['US-MT', 0.000332],['US-MS', 0.030551],['US-SC', 0.015611],['US-KY', 0.003996],['US-OR', 0.001336],['US-SD', 0.000000],
NON-RICH AND EDUCATED NATIVE: 
['US-WA', 0.003399],['US-DE', 0.000000],['US-DC', 0.000389],['US-WI', 0.000000],['US-WV', 0.000000],['US-HI', 0.000925],['US-FL', 0.000631],['US-WY', 0.000460],['US-NH', 0.000476],['US-NJ', 0.000000],['US-NM', 0.004441],['US-TX', 0.000826],['US-LA', 0.000303],['US-NC', 0.001459],['US-ND', 0.003050],['US-NE', 0.000000],['US-TN', 0.000377],['US-NY', 0.000163],['US-PA', 0.000000],['US-CA', 0.000576],['US-NV', 0.002212],['US-VA', 0.000353],['US-CO', 0.000000],['US-AK', 0.004852],['US-AL', 0.000677],['US-AR', 0.000000],['US-VT', 0.000000],['US-IL', 0.000234],['US-GA', 0.000000],['US-IN', 0.000000],['US-IA', 0.000587],['US-OK', 0.003835],['US-AZ', 0.002934],['US-ID', 0.000939],['US-CT', 0.000000],['US-ME', 0.000000],['US-MD', 0.000956],['US-MA', 0.000000],['US-OH', 0.000000],['US-UT', 0.000862],['US-MO', 0.000489],['US-MN', 0.000000],['US-MI', 0.000598],['US-RI', 0.000000],['US-KS', 0.001618],['US-MT', 0.002653],['US-MS', 0.000000],['US-SC', 0.000000],['US-KY', 0.000000],['US-OR', 0.000445],['US-SD', 0.002377],
NON-RICH AND EDUCATED ASIAN: 
['US-WA', 0.012085],['US-DE', 0.006104],['US-DC', 0.013230],['US-WI', 0.002754],['US-WV', 0.002025],['US-HI', 0.053654],['US-FL', 0.003630],['US-WY', 0.000460],['US-NH', 0.004282],['US-NJ', 0.015944],['US-NM', 0.001850],['US-TX', 0.009673],['US-LA', 0.004847],['US-NC', 0.004669],['US-ND', 0.005229],['US-NE', 0.003813],['US-TN', 0.003395],['US-NY', 0.017109],['US-PA', 0.003282],['US-CA', 0.024194],['US-NV', 0.014934],['US-VA', 0.010236],['US-CO', 0.003426],['US-AK', 0.009704],['US-AL', 0.004064],['US-AR', 0.001547],['US-VT', 0.003139],['US-IL', 0.015215],['US-GA', 0.009639],['US-IN', 0.002646],['US-IA', 0.004110],['US-OK', 0.002983],['US-AZ', 0.003353],['US-ID', 0.001877],['US-CT', 0.010579],['US-ME', 0.002519],['US-MD', 0.007652],['US-MA', 0.011653],['US-OH', 0.006444],['US-UT', 0.002587],['US-MO', 0.001467],['US-MN', 0.003844],['US-MI', 0.007780],['US-RI', 0.006297],['US-KS', 0.004854],['US-MT', 0.000663],['US-MS', 0.001421],['US-SC', 0.001784],['US-KY', 0.005495],['US-OR', 0.005788],['US-SD', 0.002971],
NON-RICH AND EDUCATED ISLANDER: 
['US-WA', 0.000755],['US-DE', 0.000000],['US-DC', 0.000389],['US-WI', 0.000000],['US-WV', 0.000000],['US-HI', 0.009713],['US-FL', 0.000000],['US-WY', 0.000000],['US-NH', 0.000000],['US-NJ', 0.000319],['US-NM', 0.000000],['US-TX', 0.000354],['US-LA', 0.000303],['US-NC', 0.000292],['US-ND', 0.000000],['US-NE', 0.000000],['US-TN', 0.000000],['US-NY', 0.000815],['US-PA', 0.000000],['US-CA', 0.000576],['US-NV', 0.000553],['US-VA', 0.000000],['US-CO', 0.000979],['US-AK', 0.001617],['US-AL', 0.000000],['US-AR', 0.000000],['US-VT', 0.000000],['US-IL', 0.000468],['US-GA', 0.000622],['US-IN', 0.000000],['US-IA', 0.000587],['US-OK', 0.000000],['US-AZ', 0.000000],['US-ID', 0.000939],['US-CT', 0.000000],['US-ME', 0.000000],['US-MD', 0.000000],['US-MA', 0.000000],['US-OH', 0.000496],['US-UT', 0.000862],['US-MO', 0.000000],['US-MN', 0.000000],['US-MI', 0.000000],['US-RI', 0.000000],['US-KS', 0.000000],['US-MT', 0.000000],['US-MS', 0.000000],['US-SC', 0.000000],['US-KY', 0.000000],['US-OR', 0.000890],['US-SD', 0.000000],
NON-RICH AND EDUCATED MULTI: 
['US-WA', 0.001888],['US-DE', 0.000555],['US-DC', 0.001556],['US-WI', 0.000918],['US-WV', 0.001446],['US-HI', 0.006938],['US-FL', 0.000631],['US-WY', 0.001838],['US-NH', 0.001427],['US-NJ', 0.001276],['US-NM', 0.001480],['US-TX', 0.001180],['US-LA', 0.000909],['US-NC', 0.001167],['US-ND', 0.000436],['US-NE', 0.001089],['US-TN', 0.001132],['US-NY', 0.000978],['US-PA', 0.002344],['US-CA', 0.001646],['US-NV', 0.001659],['US-VA', 0.002118],['US-CO', 0.000979],['US-AK', 0.000539],['US-AL', 0.001355],['US-AR', 0.000387],['US-VT', 0.002242],['US-IL', 0.000702],['US-GA', 0.001555],['US-IN', 0.001323],['US-IA', 0.001762],['US-OK', 0.002983],['US-AZ', 0.003772],['US-ID', 0.000000],['US-CT', 0.000000],['US-ME', 0.001889],['US-MD', 0.000956],['US-MA', 0.001412],['US-OH', 0.000743],['US-UT', 0.000431],['US-MO', 0.001956],['US-MN', 0.000481],['US-MI', 0.002394],['US-RI', 0.001259],['US-KS', 0.001618],['US-MT', 0.000332],['US-MS', 0.000000],['US-SC', 0.000000],['US-KY', 0.000500],['US-OR', 0.001336],['US-SD', 0.000594],
In [58]:
#Use these to store each group count to be displayed
#with its corresponding state

#NON-RICH AND NON-EDUCATED
displayDW = ""
displayDB = ""
displayDI = ""
displayDA = ""
displayDH = ""
displayDM = ""

for state in state_count:
    #store the percentage of population group of each state
    groupDW = state_count[state][18]/float(state_count[state][24])
    groupDB = state_count[state][19]/float(state_count[state][24])
    groupDI = state_count[state][20]/float(state_count[state][24])
    groupDA = state_count[state][21]/float(state_count[state][24])
    groupDH = state_count[state][22]/float(state_count[state][24])
    groupDM = state_count[state][23]/float(state_count[state][24])
    
    #store these states with group value
    #these will be used as a tooltip on our map
    displayDW += "['US-%s', %f]," % (state,groupDW)
    displayDB += "['US-%s', %f]," % (state,groupDB)
    displayDI += "['US-%s', %f]," % (state,groupDI)
    displayDA += "['US-%s', %f]," % (state,groupDA)
    displayDH += "['US-%s', %f]," % (state,groupDH)
    displayDM += "['US-%s', %f]," % (state,groupDM)

print 'NON-RICH AND NON-EDUCATED WHITE: '    
print displayDW
print 'NON-RICH AND NON-EDUCATED BLACK: '    
print displayDB
print 'NON-RICH AND NON-EDUCATED NATIVE: '    
print displayDI
print 'NON-RICH AND NON-EDUCATED ASIAN: '    
print displayDA
print 'NON-RICH AND NON-EDUCATED ISLANDER: '    
print displayDH
print 'NON-RICH AND NON-EDUCATED MULTI: '    
print displayDM
NON-RICH AND NON-EDUCATED WHITE: 
['US-WA', 0.408233],['US-DE', 0.381798],['US-DC', 0.047471],['US-WI', 0.546581],['US-WV', 0.593000],['US-HI', 0.117021],['US-FL', 0.454072],['US-WY', 0.503676],['US-NH', 0.415794],['US-NJ', 0.312181],['US-NM', 0.499630],['US-TX', 0.458535],['US-LA', 0.377158],['US-NC', 0.411730],['US-ND', 0.441394],['US-NE', 0.508170],['US-TN', 0.477178],['US-NY', 0.344794],['US-PA', 0.439991],['US-CA', 0.438199],['US-NV', 0.420907],['US-VA', 0.324391],['US-CO', 0.437102],['US-AK', 0.294879],['US-AL', 0.397900],['US-AR', 0.504062],['US-VT', 0.435874],['US-IL', 0.395599],['US-GA', 0.362873],['US-IN', 0.506614],['US-IA', 0.566060],['US-OK', 0.464849],['US-AZ', 0.479044],['US-ID', 0.587048],['US-CT', 0.341314],['US-ME', 0.484887],['US-MD', 0.241033],['US-MA', 0.338277],['US-OH', 0.487485],['US-UT', 0.526951],['US-MO', 0.449389],['US-MN', 0.444978],['US-MI', 0.461700],['US-RI', 0.411839],['US-KS', 0.462244],['US-MT', 0.517573],['US-MS', 0.366963],['US-SC', 0.376896],['US-KY', 0.575924],['US-OR', 0.489314],['US-SD', 0.507427],
NON-RICH AND NON-EDUCATED BLACK: 
['US-WA', 0.016994],['US-DE', 0.133185],['US-DC', 0.243969],['US-WI', 0.033961],['US-WV', 0.019960],['US-HI', 0.021739],['US-FL', 0.096907],['US-WY', 0.005974],['US-NH', 0.007612],['US-NJ', 0.068878],['US-NM', 0.011103],['US-TX', 0.077032],['US-LA', 0.216601],['US-NC', 0.131894],['US-ND', 0.023094],['US-NE', 0.035403],['US-TN', 0.098831],['US-NY', 0.090435],['US-PA', 0.056493],['US-CA', 0.032916],['US-NV', 0.060841],['US-VA', 0.114366],['US-CO', 0.024474],['US-AK', 0.026954],['US-AL', 0.169319],['US-AR', 0.098646],['US-VT', 0.001345],['US-IL', 0.065309],['US-GA', 0.212376],['US-IN', 0.052469],['US-IA', 0.024075],['US-OK', 0.045590],['US-AZ', 0.036044],['US-ID', 0.004223],['US-CT', 0.057350],['US-ME', 0.001259],['US-MD', 0.147298],['US-MA', 0.043785],['US-OH', 0.082280],['US-UT', 0.004743],['US-MO', 0.073350],['US-MN', 0.040365],['US-MI', 0.092759],['US-RI', 0.037783],['US-KS', 0.037217],['US-MT', 0.006631],['US-MS', 0.264298],['US-SC', 0.187333],['US-KY', 0.039461],['US-OR', 0.009795],['US-SD', 0.013666],
NON-RICH AND NON-EDUCATED NATIVE: 
['US-WA', 0.018505],['US-DE', 0.002220],['US-DC', 0.001556],['US-WI', 0.002754],['US-WV', 0.002025],['US-HI', 0.001850],['US-FL', 0.000473],['US-WY', 0.010110],['US-NH', 0.001427],['US-NJ', 0.000000],['US-NM', 0.108438],['US-TX', 0.004247],['US-LA', 0.003332],['US-NC', 0.015465],['US-ND', 0.035730],['US-NE', 0.017429],['US-TN', 0.000754],['US-NY', 0.005703],['US-PA', 0.003751],['US-CA', 0.004608],['US-NV', 0.038164],['US-VA', 0.001059],['US-CO', 0.004405],['US-AK', 0.097035],['US-AL', 0.000000],['US-AR', 0.001934],['US-VT', 0.000448],['US-IL', 0.001170],['US-GA', 0.002177],['US-IN', 0.000882],['US-IA', 0.004110],['US-OK', 0.057094],['US-AZ', 0.021375],['US-ID', 0.005631],['US-CT', 0.000557],['US-ME', 0.008186],['US-MD', 0.000478],['US-MA', 0.001766],['US-OH', 0.000496],['US-UT', 0.008193],['US-MO', 0.003912],['US-MN', 0.007689],['US-MI', 0.002992],['US-RI', 0.013854],['US-KS', 0.005394],['US-MT', 0.025199],['US-MS', 0.001066],['US-SC', 0.002230],['US-KY', 0.001998],['US-OR', 0.003562],['US-SD', 0.064765],
NON-RICH AND NON-EDUCATED ASIAN: 
['US-WA', 0.030211],['US-DE', 0.002775],['US-DC', 0.003891],['US-WI', 0.014227],['US-WV', 0.000289],['US-HI', 0.196577],['US-FL', 0.010101],['US-WY', 0.000919],['US-NH', 0.006185],['US-NJ', 0.023916],['US-NM', 0.009623],['US-TX', 0.018403],['US-LA', 0.007573],['US-NC', 0.009338],['US-ND', 0.006100],['US-NE', 0.008715],['US-TN', 0.006790],['US-NY', 0.037478],['US-PA', 0.011252],['US-CA', 0.056205],['US-NV', 0.030420],['US-VA', 0.012001],['US-CO', 0.009790],['US-AK', 0.049596],['US-AL', 0.006773],['US-AR', 0.005029],['US-VT', 0.002691],['US-IL', 0.017088],['US-GA', 0.014614],['US-IN', 0.008377],['US-IA', 0.012918],['US-OK', 0.011078],['US-AZ', 0.011316],['US-ID', 0.003754],['US-CT', 0.010022],['US-ME', 0.010705],['US-MD', 0.021999],['US-MA', 0.019068],['US-OH', 0.005948],['US-UT', 0.010781],['US-MO', 0.002934],['US-MN', 0.018260],['US-MI', 0.006882],['US-RI', 0.014484],['US-KS', 0.019957],['US-MT', 0.002653],['US-MS', 0.001421],['US-SC', 0.002676],['US-KY', 0.008492],['US-OR', 0.015583],['US-SD', 0.007724],
NON-RICH AND NON-EDUCATED ISLANDER: 
['US-WA', 0.003399],['US-DE', 0.000000],['US-DC', 0.000000],['US-WI', 0.000000],['US-WV', 0.000000],['US-HI', 0.110083],['US-FL', 0.000158],['US-WY', 0.000000],['US-NH', 0.000476],['US-NJ', 0.000000],['US-NM', 0.000000],['US-TX', 0.001180],['US-LA', 0.000000],['US-NC', 0.001167],['US-ND', 0.000436],['US-NE', 0.000000],['US-TN', 0.002263],['US-NY', 0.004888],['US-PA', 0.000469],['US-CA', 0.004855],['US-NV', 0.009403],['US-VA', 0.002471],['US-CO', 0.000489],['US-AK', 0.005391],['US-AL', 0.003048],['US-AR', 0.003868],['US-VT', 0.000448],['US-IL', 0.000936],['US-GA', 0.001555],['US-IN', 0.001764],['US-IA', 0.001174],['US-OK', 0.003409],['US-AZ', 0.006287],['US-ID', 0.002816],['US-CT', 0.000000],['US-ME', 0.000000],['US-MD', 0.000000],['US-MA', 0.000000],['US-OH', 0.000248],['US-UT', 0.009056],['US-MO', 0.000978],['US-MN', 0.000000],['US-MI', 0.000000],['US-RI', 0.000000],['US-KS', 0.000000],['US-MT', 0.000995],['US-MS', 0.000355],['US-SC', 0.001338],['US-KY', 0.000000],['US-OR', 0.004452],['US-SD', 0.000594],
NON-RICH AND NON-EDUCATED MULTI: 
['US-WA', 0.143127],['US-DE', 0.182020],['US-DC', 0.260311],['US-WI', 0.112896],['US-WV', 0.173561],['US-HI', 0.204440],['US-FL', 0.174716],['US-WY', 0.160386],['US-NH', 0.182683],['US-NJ', 0.150191],['US-NM', 0.142487],['US-TX', 0.142975],['US-LA', 0.137231],['US-NC', 0.158156],['US-ND', 0.175163],['US-NE', 0.119826],['US-TN', 0.164466],['US-NY', 0.169627],['US-PA', 0.147211],['US-CA', 0.101712],['US-NV', 0.162611],['US-VA', 0.129898],['US-CO', 0.121880],['US-AK', 0.201078],['US-AL', 0.183542],['US-AR', 0.155513],['US-VT', 0.219283],['US-IL', 0.105103],['US-GA', 0.143968],['US-IN', 0.150794],['US-IA', 0.117440],['US-OK', 0.172561],['US-AZ', 0.169321],['US-ID', 0.114500],['US-CT', 0.140869],['US-ME', 0.229219],['US-MD', 0.163080],['US-MA', 0.177613],['US-OH', 0.138786],['US-UT', 0.098749],['US-MO', 0.169682],['US-MN', 0.123498],['US-MI', 0.159785],['US-RI', 0.165617],['US-KS', 0.160734],['US-MT', 0.148873],['US-MS', 0.166607],['US-SC', 0.167261],['US-KY', 0.144855],['US-OR', 0.121549],['US-SD', 0.115865],

Setup Rich and Educated Maps

In [59]:
#create google map with the data we set
def write_html(grp,rep):
    html = ""
    with open('map.html') as f:
        for line in f.readlines():
            if 'REPLACE_ME' in line:
                html += rep
            else:
                html += line

    with open("index-%s.html" % (grp),"w") as f:
         f.write(html)

write_html('aw',displayAW)
write_html('ab',displayAB)
write_html('ai',displayAI)
write_html('aa',displayAA)
write_html('ah',displayAH)
write_html('am',displayAM)

Rich and Educated Maps

Race: White Only

In [60]:
from IPython.display import IFrame
IFrame('index-aw.html', width=700, height=400)
Out[60]:

Race: Black Only

In [61]:
from IPython.display import IFrame
IFrame('index-ab.html', width=700, height=400)
Out[61]:

Race: American Indian, Alaskan Native Only

In [62]:
from IPython.display import IFrame
IFrame('index-ai.html', width=700, height=400)
Out[62]:

Race: Asian Only

In [63]:
from IPython.display import IFrame
IFrame('index-aa.html', width=700, height=400)
Out[63]:

Race: Hawaiian/Pacific Islander Only

In [64]:
from IPython.display import IFrame
IFrame('index-ah.html', width=700, height=400)
Out[64]:

Race: Multi-Racial (Self Identifies as a combination of 2 or more races)

In [65]:
from IPython.display import IFrame
IFrame('index-am.html', width=700, height=400)
Out[65]:

Setup Rich and Uneducated Maps

In [66]:
#create google map with the data we set
def write_html(grp,rep):
    html = ""
    with open('map.html') as f:
        for line in f.readlines():
            if 'REPLACE_ME' in line:
                html += rep
            else:
                html += line

    with open("index-%s.html" % (grp),"w") as f:
         f.write(html)

write_html('bw',displayBW)
write_html('bb',displayBB)
write_html('bi',displayBI)
write_html('ba',displayBA)
write_html('bh',displayBH)
write_html('bm',displayBM)

Rich and Uneducated Maps

Race: White Only

In [67]:
from IPython.display import IFrame
IFrame('index-bw.html', width=700, height=400)
Out[67]:

Race: Black Only

In [68]:
from IPython.display import IFrame
IFrame('index-bb.html', width=700, height=400)
Out[68]:

Race: American Indian, Alaskan Native Only

In [69]:
from IPython.display import IFrame
IFrame('index-bi.html', width=700, height=400)
Out[69]:

Race: Asian Only

In [70]:
from IPython.display import IFrame
IFrame('index-ba.html', width=700, height=400)
Out[70]:

Race: Hawaiian/Pacific Islander Only

In [71]:
from IPython.display import IFrame
IFrame('index-bh.html', width=700, height=400)
Out[71]:

Race: Multi-Racial (Self Identifies as a combination of 2 or more races)

In [72]:
from IPython.display import IFrame
IFrame('index-bm.html', width=700, height=400)
Out[72]:

Setup Non-Rich and Educated Maps

In [73]:
#create google map with the data we set
def write_html(grp,rep):
    html = ""
    with open('map.html') as f:
        for line in f.readlines():
            if 'REPLACE_ME' in line:
                html += rep
            else:
                html += line

    with open("index-%s.html" % (grp),"w") as f:
         f.write(html)

write_html('cw',displayCW)
write_html('cb',displayCB)
write_html('ci',displayCI)
write_html('ca',displayCA)
write_html('ch',displayCH)
write_html('cm',displayCM)

Non-Rich and Educated Maps

Race: White Only

In [74]:
from IPython.display import IFrame
IFrame('index-cw.html', width=700, height=400)
Out[74]:

Race: Black Only

In [75]:
from IPython.display import IFrame
IFrame('index-cb.html', width=700, height=400)
Out[75]:

Race: American Indian, Alaskan Native Only

In [76]:
from IPython.display import IFrame
IFrame('index-ci.html', width=700, height=400)
Out[76]:

Race: Asian Only

In [77]:
from IPython.display import IFrame
IFrame('index-ca.html', width=700, height=400)
Out[77]:

Race: Hawaiian/Pacific Islander Only

In [78]:
from IPython.display import IFrame
IFrame('index-ch.html', width=700, height=400)
Out[78]:

Race: Multi-Racial (Self Identifies as a combination of 2 or more races)

In [79]:
from IPython.display import IFrame
IFrame('index-cm.html', width=700, height=400)
Out[79]:

Setup Non-Rich and Uneducated Maps

In [80]:
#create google map with the data we set
def write_html(grp,rep):
    html = ""
    with open('map.html') as f:
        for line in f.readlines():
            if 'REPLACE_ME' in line:
                html += rep
            else:
                html += line

    with open("index-%s.html" % (grp),"w") as f:
         f.write(html)

write_html('dw',displayDW)
write_html('db',displayDB)
write_html('di',displayDI)
write_html('da',displayDA)
write_html('dh',displayDH)
write_html('dm',displayDM)

Non-Rich and Uneducated Maps

Race: White Only

In [81]:
from IPython.display import IFrame
IFrame('index-dw.html', width=700, height=400)
Out[81]:

Race: Black Only

In [82]:
from IPython.display import IFrame
IFrame('index-db.html', width=700, height=400)
Out[82]:

Race: American Indian, Alaskan Native Only

In [83]:
from IPython.display import IFrame
IFrame('index-di.html', width=700, height=400)
Out[83]:

Race: Asian Only

In [84]:
from IPython.display import IFrame
IFrame('index-da.html', width=700, height=400)
Out[84]:

Race: Hawaiian/Pacific Islander Only

In [85]:
from IPython.display import IFrame
IFrame('index-dh.html', width=700, height=400)
Out[85]:

Race: Multi-Racial (Self Identifies as a combination of 2 or more races)

In [86]:
from IPython.display import IFrame
IFrame('index-dm.html', width=700, height=400)
Out[86]: