diff --git a/cluster_by_demo_and_license.R b/cluster_by_demo_and_license.R
new file mode 100644
index 0000000..a171363
--- /dev/null
+++ b/cluster_by_demo_and_license.R
@@ -0,0 +1,73 @@
+library(dplyr)
+library(reshape2)
+library(ggplot2)
+library(rgdal)
+library(maptools)
+options(stringsAsFactors = F)
+
+load('output/crime_census_alcohol.rda')
+
+# check out dimension
+summary(crime_census_alcohol)
+
+# transform variables
+crime_census_alcohol$med_income = (crime_census_alcohol$med_income - min(crime_census_alcohol$med_income)) /
+ (max(crime_census_alcohol$med_income) - min(crime_census_alcohol$med_income))
+crime_census_alcohol$Unemploy_p = crime_census_alcohol$Unemploy_p / 100
+
+# check out small populations
+hist(crime_census_alcohol$Pop2010)
+summary(crime_census_alcohol$Pop2010[crime_census_alcohol$Pop2010 < 2000])
+
+# throw out tracts with populations less than 500
+crime_census_alcohol = subset(crime_census_alcohol, Pop2010 >= 500)
+
+# k-means clustering
+names(crime_census_alcohol)[3:8] = paste('demo', tolower(names(crime_census_alcohol)[3:8]), sep = '_')
+census_alcohol = crime_census_alcohol %>%
+ select(starts_with('demo'), starts_with('license'))
+
+do_kmeans = function(dat, k) {
+ model = kmeans(dat, k)
+
+ kmeans_result = list()
+ kmeans_result$within = model$tot.withinss
+ kmeans_result$between = model$betweenss
+ kmeans_result$cluster = model$cluster
+
+ kmeans_result
+}
+
+kmeans_results = lapply(1:40, function(x) do_kmeans(census_alcohol, x))
+
+# plot results
+kmeans_dists = data.frame(
+ k = 1:40,
+ within = sapply(kmeans_results, function(x) x$within),
+ between = sapply(kmeans_results, function(x) x$between)
+ )
+kmeans_dists_long = melt(kmeans_dists, id = 'k')
+kmeans_dists_plot =
+ ggplot(kmeans_dists_long, aes(x = k, y = value, colour = variable)) +
+ geom_line()
+
+# 20 appears to be a good number of clusters
+crime_census_alcohol$cluster = kmeans_results[[20]]$cluster
+
+# pick alcohol-related crimes
+relevant_crimes = 'arson|assault|burglary|disorderly_conduct|driving_under_the_influence|drunkenness|liquor_laws|prostitution|robbery|sex_offenses|vandalism'
+
+# calculate aggregate crime rate
+crime_census_alcohol = crime_census_alcohol %>%
+ select(Tract2010, Pop2010, starts_with('demo'), starts_with('license'), cluster) %>%
+ cbind(crime_census_alcohol[names(crime_census_alcohol)[grep(relevant_crimes, names(crime_census_alcohol))]])
+
+crime_census_alcohol$agg_crime = rowSums(crime_census_alcohol[names(crime_census_alcohol)[grep('crime', names(crime_census_alcohol))]])
+
+# calculate the variance of crimes within each cluster
+crime_per_cluster = crime_census_alcohol %>%
+ group_by(cluster) %>%
+ summarise(agg_crime_var = var(agg_crime))
+
+write.csv(crime_census_alcohol, file = 'output/crime_census_alcohol.csv', row.names = F)
+write.csv(crime_per_cluster, file = 'output/crime_per_cluster.csv', row.names = F)
diff --git a/datasf_crime_pull_preprocess.py b/datasf_crime_pull_preprocess.py
new file mode 100644
index 0000000..0f5255a
--- /dev/null
+++ b/datasf_crime_pull_preprocess.py
@@ -0,0 +1,107 @@
+"""
+Code to pull DataSF.org Crime data and preprocess it on a scheduled basis with Linux crond. UNTESTED. More annotation pending.
+"""
+
+import pandas as pd
+import os
+import urllib2
+import numpy as np
+import json
+import pyproj
+
+def main():
+ """
+
+ """
+ # pull json of Crime... from datasf.org
+ jsonurl = 'https://data.sfgov.org/api/views/gxxq-x39z/rows.json?accessType=DOWNLOAD'
+ os.system("wget "+jsonurl+" > out.json")
+
+ # read result of wget pull
+ with open("out.json") as f:
+ data = f.read()
+
+ data = json.loads(data)
+ columns = [data["meta"]["view"]["columns"][i]['fieldName'].replace(":","") for i in range(len(data["meta"]["view"]["columns"]))]
+ df = pd.DataFrame(data["data"], columns=columns)
+
+ # Merge date and time
+ for i in ['date', 'time']:
+ if df[i].dtype == 'datetime64[ns]':
+ df[i] = [str(x) for x in df[i]]
+
+ df['datetime'] = None
+
+ df.datetime = [x[0:10]+' '+y for x,y in zip(df.date,df.time)]
+ del df['date']
+ del df['time']
+
+ df.datetime = pd.to_datetime(df.datetime, format = '%Y-%m-%d %H:%M')
+
+ df = df.sort(columns =['incidntnum', 'datetime']).reset_index(drop = True)
+
+ # Cut resolution
+ these = ['UNFOUNDED', 'CLEARED-CONTACT JUVENILE FOR MORE INFO', 'EXCEPTIONAL CLEARANCE']
+ df = df[~df.resolution.isin(these)].reset_index(drop = True)
+
+ # Cut all before 2010
+ df = df[df.datetime > pd.to_datetime('2010', format = '%Y')].reset_index(drop = True)
+
+ # Cut Category (s)
+ keepthese = ['SUICIDE','SEX OFFENSES, FORCIBLE','ASSAULT','ROBBERY','WEAPON LAWS','DRUG/NARCOTIC',\
+ 'DRUNKENNESS','DRIVING UNDER THE INFLUENCE','DISORDERLY CONDUCT','LIQUOR LAWS',\
+ 'VANDALISM','FAMILY OFFENSES','PROSTITUTION','SEX OFFENSES, NON FORCIBLE','TRESPASS',\
+ 'LOITERING','SUSPICIOUS OCC']
+
+ df = df[df.category.isin(keepthese)].reset_index(drop = True)
+
+ # Throw out garbage columns
+ keepthese = ['incidntnum','category','descript','dayofweek','pddistrict','resolution','address','x','y','datetime']
+ df = df[keepthese]
+
+ # add Coarse Category
+ violence = ['SEX OFFENSES, FORCIBLE', 'SEX OFFENSES, NON FORCIBLE','ASSAULT','ROBBERY','WEAPON LAWS','SUICIDE', 'FAMILY OFFENSES']
+ vandalism = ['SUSPICIOUS OCC', 'VANDALISM', 'TRESPASS']
+ drugs = ['DRUG/NARCOTIC']
+ alcohol = ['LIQUOR LAWS','DRUNKENNESS','DISORDERLY CONDUCT', 'LOITERING']
+ prostitution = ['PROSTITUTION']
+ dui = ['DRIVING UNDER THE INFLUENCE']
+
+ df['CoarseCategroy'] = None
+ for i in df.index:
+ if df.category[i] in violence:
+ df['CoarseCategroy'][i] = 'violence'
+ if df.category[i] in vandalism:
+ df['CoarseCategroy'][i] = 'vandalism'
+ if df.category[i] in drugs:
+ df['CoarseCategroy'][i] = 'drugs'
+ if df.category[i] in alcohol:
+ df['CoarseCategroy'][i] = 'alcohol'
+ if df.category[i] in prostitution:
+ df['CoarseCategroy'][i] = 'prostitution'
+ if df.category[i] in dui:
+ df['CoarseCategroy'][i] = 'dui'
+
+ # add Coarse descriptor Kris code....
+
+
+
+
+
+ # Call Nick's function with RPy2
+ isn2004=pyproj.Proj("+proj=lcc +lat_1=38.43333333333333 +lat_2=37.06666666666667 +lat_0=36.5 +lon_0=-120.5 +x_0=2000000 +y_0=500000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs")
+ df.x = df.x.astype(float)
+ df.y = df.y.astype(float)
+
+ tmp = [isn2004(df.x[i],df.y[i]) for i in range(len(df))]
+ tmp = zip(*tmp)
+ df["newx"] = tmp[0]
+ df["newy"] = tmp[1]
+
+ return df
+
+
+if __name__ == '__main__':
+ main()
+
+
diff --git a/filter_census_tract_data.ipynb b/filter_census_tract_data.ipynb
index 581e417..92ae934 100644
--- a/filter_census_tract_data.ipynb
+++ b/filter_census_tract_data.ipynb
@@ -11,7 +11,7 @@
},
{
"cell_type": "code",
- "execution_count": 56,
+ "execution_count": 245,
"metadata": {
"collapsed": false
},
@@ -30,7 +30,7 @@
},
{
"cell_type": "code",
- "execution_count": 57,
+ "execution_count": 246,
"metadata": {
"collapsed": true
},
@@ -42,7 +42,7 @@
},
{
"cell_type": "code",
- "execution_count": 58,
+ "execution_count": 247,
"metadata": {
"collapsed": false
},
@@ -51,12 +51,12 @@
"path_base = (\"/Users/brian/Google Drive/\")\n",
"path_specfic = \"SPHIP/2009-2013 ACS Demographic Data/Census Tract Data Files and Documentation/\"\n",
"years = ['2', '3', '4', '5']\n",
- "year = years[0] # Later this will 'for year in years:'"
+ "year = years[0]"
]
},
{
"cell_type": "code",
- "execution_count": 59,
+ "execution_count": 248,
"metadata": {
"collapsed": false
},
@@ -65,8 +65,10 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "DP05\n",
- "ACS DEMOGRAPHIC AND HOUSING ESTIMATES\n",
+ "File: ACS_13_5YR_DP02.txt\n",
+ "\n",
+ "DP02\n",
+ "SELECTED SOCIAL CHARACTERISTICS IN THE UNITED STATES\n",
"\n",
"Although the American Community Survey (ACS) produces population, demographic and housing unit estimates, it is the Census Bureau's Population Estimates Program that produces and disseminates the official estimates of the population for the nation, states, counties, cities and towns and estimates of housing units for states and counties.\n",
"\n",
@@ -79,13 +81,14 @@
"Source: U.S. Census Bureau, 2009-2013 5-Year American Community Survey\n",
"\n",
"\n",
- "Explanation of Symbols:An '**' entry in the margin of error column indicates that either no sample observations or too few sample observations were available t\n",
+ "Explanation of Symbols:An '**' entry in the margin of error column indicates that either no sample observations or too few sample observations w\n",
"...\n"
]
}
],
"source": [
"file_name = 'ACS_13_5YR_DP0'+year+'.txt'\n",
+ "print('File: '+file_name+'\\n')\n",
"with open(path_base+path_specfic+file_name) as f:\n",
" text_description = f.read()\n",
"print(text_description[:1000])\n",
@@ -94,67 +97,11 @@
},
{
"cell_type": "code",
- "execution_count": 60,
+ "execution_count": 249,
"metadata": {
"collapsed": false
},
- "outputs": [
- {
- "data": {
- "text/html": [
- "
\n",
- "
\n",
- " \n",
- " \n",
- " | \n",
- " data_column_name | \n",
- " description | \n",
- "
\n",
- " \n",
- " \n",
- " \n",
- " 0 | \n",
- " GEO.id | \n",
- " Id | \n",
- "
\n",
- " \n",
- " 1 | \n",
- " GEO.id2 | \n",
- " Id2 | \n",
- "
\n",
- " \n",
- " 2 | \n",
- " GEO.display-label | \n",
- " Geography | \n",
- "
\n",
- " \n",
- " 3 | \n",
- " HC01_VC03 | \n",
- " Estimate; SEX AND AGE - Total population | \n",
- "
\n",
- " \n",
- " 4 | \n",
- " HC02_VC03 | \n",
- " Margin of Error; SEX AND AGE - Total population | \n",
- "
\n",
- " \n",
- "
\n",
- "
"
- ],
- "text/plain": [
- " data_column_name description\n",
- "0 GEO.id Id\n",
- "1 GEO.id2 Id2\n",
- "2 GEO.display-label Geography\n",
- "3 HC01_VC03 Estimate; SEX AND AGE - Total population\n",
- "4 HC02_VC03 Margin of Error; SEX AND AGE - Total population"
- ]
- },
- "execution_count": 60,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
+ "outputs": [],
"source": [
"# Load meta data\n",
"file_name = \"ACS_13_5YR_DP0\"+year+\"_metadata.csv\"\n",
@@ -162,12 +109,12 @@
"df_meta = pd.read_csv(path_name,\n",
" header=None)\n",
"df_meta.columns = ['data_column_name', 'description']\n",
- "df_meta.head()"
+ "# df_meta.head()"
]
},
{
"cell_type": "code",
- "execution_count": 70,
+ "execution_count": 250,
"metadata": {
"collapsed": false
},
@@ -188,7 +135,7 @@
},
{
"cell_type": "code",
- "execution_count": 63,
+ "execution_count": 251,
"metadata": {
"collapsed": false
},
@@ -199,7 +146,7 @@
"True"
]
},
- "execution_count": 63,
+ "execution_count": 251,
"metadata": {},
"output_type": "execute_result"
}
@@ -211,7 +158,7 @@
},
{
"cell_type": "code",
- "execution_count": 71,
+ "execution_count": 252,
"metadata": {
"collapsed": false
},
@@ -248,7 +195,7 @@
},
{
"cell_type": "code",
- "execution_count": 86,
+ "execution_count": 290,
"metadata": {
"collapsed": false
},
@@ -257,515 +204,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "data dictionary\n",
- "{'geo_display_label': 'Id2',\n",
- " 'geo_id': 'Id',\n",
- " 'hc01_vc03': 'Estimate; SEX AND AGE - Total population',\n",
- " 'hc01_vc04': 'Estimate; SEX AND AGE - Total population - Male',\n",
- " 'hc01_vc05': 'Estimate; SEX AND AGE - Total population - Female',\n",
- " 'hc01_vc08': 'Estimate; SEX AND AGE - Under 5 years',\n",
- " 'hc01_vc09': 'Estimate; SEX AND AGE - 5 to 9 years',\n",
- " 'hc01_vc10': 'Estimate; SEX AND AGE - 10 to 14 years',\n",
- " 'hc01_vc100': 'Estimate; HISPANIC OR LATINO AND RACE - Total population - '\n",
- " 'Not Hispanic or Latino - Two or more races',\n",
- " 'hc01_vc101': 'Estimate; HISPANIC OR LATINO AND RACE - Total population - '\n",
- " 'Not Hispanic or Latino - Two or more races - Two races '\n",
- " 'including Some other race',\n",
- " 'hc01_vc102': 'Estimate; HISPANIC OR LATINO AND RACE - Total population - '\n",
- " 'Not Hispanic or Latino - Two or more races - Two races '\n",
- " 'excluding Some other race, and Three or more races',\n",
- " 'hc01_vc104': 'Estimate; HISPANIC OR LATINO AND RACE - Total housing units',\n",
- " 'hc01_vc11': 'Estimate; SEX AND AGE - 15 to 19 years',\n",
- " 'hc01_vc12': 'Estimate; SEX AND AGE - 20 to 24 years',\n",
- " 'hc01_vc13': 'Estimate; SEX AND AGE - 25 to 34 years',\n",
- " 'hc01_vc14': 'Estimate; SEX AND AGE - 35 to 44 years',\n",
- " 'hc01_vc15': 'Estimate; SEX AND AGE - 45 to 54 years',\n",
- " 'hc01_vc16': 'Estimate; SEX AND AGE - 55 to 59 years',\n",
- " 'hc01_vc17': 'Estimate; SEX AND AGE - 60 to 64 years',\n",
- " 'hc01_vc18': 'Estimate; SEX AND AGE - 65 to 74 years',\n",
- " 'hc01_vc19': 'Estimate; SEX AND AGE - 75 to 84 years',\n",
- " 'hc01_vc20': 'Estimate; SEX AND AGE - 85 years and over',\n",
- " 'hc01_vc23': 'Estimate; SEX AND AGE - Median age (years)',\n",
- " 'hc01_vc26': 'Estimate; SEX AND AGE - 18 years and over',\n",
- " 'hc01_vc27': 'Estimate; SEX AND AGE - 21 years and over',\n",
- " 'hc01_vc28': 'Estimate; SEX AND AGE - 62 years and over',\n",
- " 'hc01_vc29': 'Estimate; SEX AND AGE - 65 years and over',\n",
- " 'hc01_vc32': 'Estimate; SEX AND AGE - 18 years and over',\n",
- " 'hc01_vc33': 'Estimate; SEX AND AGE - 18 years and over - Male',\n",
- " 'hc01_vc34': 'Estimate; SEX AND AGE - 18 years and over - Female',\n",
- " 'hc01_vc37': 'Estimate; SEX AND AGE - 65 years and over',\n",
- " 'hc01_vc38': 'Estimate; SEX AND AGE - 65 years and over - Male',\n",
- " 'hc01_vc39': 'Estimate; SEX AND AGE - 65 years and over - Female',\n",
- " 'hc01_vc43': 'Estimate; RACE - Total population',\n",
- " 'hc01_vc44': 'Estimate; RACE - Total population - One race',\n",
- " 'hc01_vc45': 'Estimate; RACE - Total population - Two or more races',\n",
- " 'hc01_vc48': 'Estimate; RACE - One race',\n",
- " 'hc01_vc49': 'Estimate; RACE - One race - White',\n",
- " 'hc01_vc50': 'Estimate; RACE - One race - Black or African American',\n",
- " 'hc01_vc51': 'Estimate; RACE - One race - American Indian and Alaska Native',\n",
- " 'hc01_vc52': 'Estimate; RACE - One race - American Indian and Alaska Native '\n",
- " '- Cherokee tribal grouping',\n",
- " 'hc01_vc53': 'Estimate; RACE - One race - American Indian and Alaska Native '\n",
- " '- Chippewa tribal grouping',\n",
- " 'hc01_vc54': 'Estimate; RACE - One race - American Indian and Alaska Native '\n",
- " '- Navajo tribal grouping',\n",
- " 'hc01_vc55': 'Estimate; RACE - One race - American Indian and Alaska Native '\n",
- " '- Sioux tribal grouping',\n",
- " 'hc01_vc56': 'Estimate; RACE - One race - Asian',\n",
- " 'hc01_vc57': 'Estimate; RACE - One race - Asian - Asian Indian',\n",
- " 'hc01_vc58': 'Estimate; RACE - One race - Asian - Chinese',\n",
- " 'hc01_vc59': 'Estimate; RACE - One race - Asian - Filipino',\n",
- " 'hc01_vc60': 'Estimate; RACE - One race - Asian - Japanese',\n",
- " 'hc01_vc61': 'Estimate; RACE - One race - Asian - Korean',\n",
- " 'hc01_vc62': 'Estimate; RACE - One race - Asian - Vietnamese',\n",
- " 'hc01_vc63': 'Estimate; RACE - One race - Asian - Other Asian',\n",
- " 'hc01_vc64': 'Estimate; RACE - One race - Native Hawaiian and Other Pacific '\n",
- " 'Islander',\n",
- " 'hc01_vc65': 'Estimate; RACE - One race - Native Hawaiian and Other Pacific '\n",
- " 'Islander - Native Hawaiian',\n",
- " 'hc01_vc66': 'Estimate; RACE - One race - Native Hawaiian and Other Pacific '\n",
- " 'Islander - Guamanian or Chamorro',\n",
- " 'hc01_vc67': 'Estimate; RACE - One race - Native Hawaiian and Other Pacific '\n",
- " 'Islander - Samoan',\n",
- " 'hc01_vc68': 'Estimate; RACE - One race - Native Hawaiian and Other Pacific '\n",
- " 'Islander - Other Pacific Islander',\n",
- " 'hc01_vc69': 'Estimate; RACE - One race - Some other race',\n",
- " 'hc01_vc70': 'Estimate; RACE - Two or more races',\n",
- " 'hc01_vc71': 'Estimate; RACE - Two or more races - White and Black or '\n",
- " 'African American',\n",
- " 'hc01_vc72': 'Estimate; RACE - Two or more races - White and American '\n",
- " 'Indian and Alaska Native',\n",
- " 'hc01_vc73': 'Estimate; RACE - Two or more races - White and Asian',\n",
- " 'hc01_vc74': 'Estimate; RACE - Two or more races - Black or African '\n",
- " 'American and American Indian and Alaska Native',\n",
- " 'hc01_vc77': 'Estimate; RACE - Race alone or in combination with one or '\n",
- " 'more other races - Total population',\n",
- " 'hc01_vc78': 'Estimate; RACE - Race alone or in combination with one or '\n",
- " 'more other races - Total population - White',\n",
- " 'hc01_vc79': 'Estimate; RACE - Race alone or in combination with one or '\n",
- " 'more other races - Total population - Black or African '\n",
- " 'American',\n",
- " 'hc01_vc80': 'Estimate; RACE - Race alone or in combination with one or '\n",
- " 'more other races - Total population - American Indian and '\n",
- " 'Alaska Native',\n",
- " 'hc01_vc81': 'Estimate; RACE - Race alone or in combination with one or '\n",
- " 'more other races - Total population - Asian',\n",
- " 'hc01_vc82': 'Estimate; RACE - Race alone or in combination with one or '\n",
- " 'more other races - Total population - Native Hawaiian and '\n",
- " 'Other Pacific Islander',\n",
- " 'hc01_vc83': 'Estimate; RACE - Race alone or in combination with one or '\n",
- " 'more other races - Total population - Some other race',\n",
- " 'hc01_vc87': 'Estimate; HISPANIC OR LATINO AND RACE - Total population',\n",
- " 'hc01_vc88': 'Estimate; HISPANIC OR LATINO AND RACE - Total population - '\n",
- " 'Hispanic or Latino (of any race)',\n",
- " 'hc01_vc89': 'Estimate; HISPANIC OR LATINO AND RACE - Total population - '\n",
- " 'Hispanic or Latino (of any race) - Mexican',\n",
- " 'hc01_vc90': 'Estimate; HISPANIC OR LATINO AND RACE - Total population - '\n",
- " 'Hispanic or Latino (of any race) - Puerto Rican',\n",
- " 'hc01_vc91': 'Estimate; HISPANIC OR LATINO AND RACE - Total population - '\n",
- " 'Hispanic or Latino (of any race) - Cuban',\n",
- " 'hc01_vc92': 'Estimate; HISPANIC OR LATINO AND RACE - Total population - '\n",
- " 'Hispanic or Latino (of any race) - Other Hispanic or Latino',\n",
- " 'hc01_vc93': 'Estimate; HISPANIC OR LATINO AND RACE - Total population - '\n",
- " 'Not Hispanic or Latino',\n",
- " 'hc01_vc94': 'Estimate; HISPANIC OR LATINO AND RACE - Total population - '\n",
- " 'Not Hispanic or Latino - White alone',\n",
- " 'hc01_vc95': 'Estimate; HISPANIC OR LATINO AND RACE - Total population - '\n",
- " 'Not Hispanic or Latino - Black or African American alone',\n",
- " 'hc01_vc96': 'Estimate; HISPANIC OR LATINO AND RACE - Total population - '\n",
- " 'Not Hispanic or Latino - American Indian and Alaska Native '\n",
- " 'alone',\n",
- " 'hc01_vc97': 'Estimate; HISPANIC OR LATINO AND RACE - Total population - '\n",
- " 'Not Hispanic or Latino - Asian alone',\n",
- " 'hc01_vc98': 'Estimate; HISPANIC OR LATINO AND RACE - Total population - '\n",
- " 'Not Hispanic or Latino - Native Hawaiian and Other Pacific '\n",
- " 'Islander alone',\n",
- " 'hc01_vc99': 'Estimate; HISPANIC OR LATINO AND RACE - Total population - '\n",
- " 'Not Hispanic or Latino - Some other race alone',\n",
- " 'hc02_vc03': 'Margin of Error; SEX AND AGE - Total population',\n",
- " 'hc02_vc04': 'Margin of Error; SEX AND AGE - Total population - Male',\n",
- " 'hc02_vc05': 'Margin of Error; SEX AND AGE - Total population - Female',\n",
- " 'hc02_vc08': 'Margin of Error; SEX AND AGE - Under 5 years',\n",
- " 'hc02_vc09': 'Margin of Error; SEX AND AGE - 5 to 9 years',\n",
- " 'hc02_vc10': 'Margin of Error; SEX AND AGE - 10 to 14 years',\n",
- " 'hc02_vc100': 'Margin of Error; HISPANIC OR LATINO AND RACE - Total '\n",
- " 'population - Not Hispanic or Latino - Two or more races',\n",
- " 'hc02_vc101': 'Margin of Error; HISPANIC OR LATINO AND RACE - Total '\n",
- " 'population - Not Hispanic or Latino - Two or more races - '\n",
- " 'Two races including Some other race',\n",
- " 'hc02_vc102': 'Margin of Error; HISPANIC OR LATINO AND RACE - Total '\n",
- " 'population - Not Hispanic or Latino - Two or more races - '\n",
- " 'Two races excluding Some other race, and Three or more races',\n",
- " 'hc02_vc104': 'Margin of Error; HISPANIC OR LATINO AND RACE - Total housing '\n",
- " 'units',\n",
- " 'hc02_vc11': 'Margin of Error; SEX AND AGE - 15 to 19 years',\n",
- " 'hc02_vc12': 'Margin of Error; SEX AND AGE - 20 to 24 years',\n",
- " 'hc02_vc13': 'Margin of Error; SEX AND AGE - 25 to 34 years',\n",
- " 'hc02_vc14': 'Margin of Error; SEX AND AGE - 35 to 44 years',\n",
- " 'hc02_vc15': 'Margin of Error; SEX AND AGE - 45 to 54 years',\n",
- " 'hc02_vc16': 'Margin of Error; SEX AND AGE - 55 to 59 years',\n",
- " 'hc02_vc17': 'Margin of Error; SEX AND AGE - 60 to 64 years',\n",
- " 'hc02_vc18': 'Margin of Error; SEX AND AGE - 65 to 74 years',\n",
- " 'hc02_vc19': 'Margin of Error; SEX AND AGE - 75 to 84 years',\n",
- " 'hc02_vc20': 'Margin of Error; SEX AND AGE - 85 years and over',\n",
- " 'hc02_vc23': 'Margin of Error; SEX AND AGE - Median age (years)',\n",
- " 'hc02_vc26': 'Margin of Error; SEX AND AGE - 18 years and over',\n",
- " 'hc02_vc27': 'Margin of Error; SEX AND AGE - 21 years and over',\n",
- " 'hc02_vc28': 'Margin of Error; SEX AND AGE - 62 years and over',\n",
- " 'hc02_vc29': 'Margin of Error; SEX AND AGE - 65 years and over',\n",
- " 'hc02_vc32': 'Margin of Error; SEX AND AGE - 18 years and over',\n",
- " 'hc02_vc33': 'Margin of Error; SEX AND AGE - 18 years and over - Male',\n",
- " 'hc02_vc34': 'Margin of Error; SEX AND AGE - 18 years and over - Female',\n",
- " 'hc02_vc37': 'Margin of Error; SEX AND AGE - 65 years and over',\n",
- " 'hc02_vc38': 'Margin of Error; SEX AND AGE - 65 years and over - Male',\n",
- " 'hc02_vc39': 'Margin of Error; SEX AND AGE - 65 years and over - Female',\n",
- " 'hc02_vc43': 'Margin of Error; RACE - Total population',\n",
- " 'hc02_vc44': 'Margin of Error; RACE - Total population - One race',\n",
- " 'hc02_vc45': 'Margin of Error; RACE - Total population - Two or more races',\n",
- " 'hc02_vc48': 'Margin of Error; RACE - One race',\n",
- " 'hc02_vc49': 'Margin of Error; RACE - One race - White',\n",
- " 'hc02_vc50': 'Margin of Error; RACE - One race - Black or African American',\n",
- " 'hc02_vc51': 'Margin of Error; RACE - One race - American Indian and Alaska '\n",
- " 'Native',\n",
- " 'hc02_vc52': 'Margin of Error; RACE - One race - American Indian and Alaska '\n",
- " 'Native - Cherokee tribal grouping',\n",
- " 'hc02_vc53': 'Margin of Error; RACE - One race - American Indian and Alaska '\n",
- " 'Native - Chippewa tribal grouping',\n",
- " 'hc02_vc54': 'Margin of Error; RACE - One race - American Indian and Alaska '\n",
- " 'Native - Navajo tribal grouping',\n",
- " 'hc02_vc55': 'Margin of Error; RACE - One race - American Indian and Alaska '\n",
- " 'Native - Sioux tribal grouping',\n",
- " 'hc02_vc56': 'Margin of Error; RACE - One race - Asian',\n",
- " 'hc02_vc57': 'Margin of Error; RACE - One race - Asian - Asian Indian',\n",
- " 'hc02_vc58': 'Margin of Error; RACE - One race - Asian - Chinese',\n",
- " 'hc02_vc59': 'Margin of Error; RACE - One race - Asian - Filipino',\n",
- " 'hc02_vc60': 'Margin of Error; RACE - One race - Asian - Japanese',\n",
- " 'hc02_vc61': 'Margin of Error; RACE - One race - Asian - Korean',\n",
- " 'hc02_vc62': 'Margin of Error; RACE - One race - Asian - Vietnamese',\n",
- " 'hc02_vc63': 'Margin of Error; RACE - One race - Asian - Other Asian',\n",
- " 'hc02_vc64': 'Margin of Error; RACE - One race - Native Hawaiian and Other '\n",
- " 'Pacific Islander',\n",
- " 'hc02_vc65': 'Margin of Error; RACE - One race - Native Hawaiian and Other '\n",
- " 'Pacific Islander - Native Hawaiian',\n",
- " 'hc02_vc66': 'Margin of Error; RACE - One race - Native Hawaiian and Other '\n",
- " 'Pacific Islander - Guamanian or Chamorro',\n",
- " 'hc02_vc67': 'Margin of Error; RACE - One race - Native Hawaiian and Other '\n",
- " 'Pacific Islander - Samoan',\n",
- " 'hc02_vc68': 'Margin of Error; RACE - One race - Native Hawaiian and Other '\n",
- " 'Pacific Islander - Other Pacific Islander',\n",
- " 'hc02_vc69': 'Margin of Error; RACE - One race - Some other race',\n",
- " 'hc02_vc70': 'Margin of Error; RACE - Two or more races',\n",
- " 'hc02_vc71': 'Margin of Error; RACE - Two or more races - White and Black '\n",
- " 'or African American',\n",
- " 'hc02_vc72': 'Margin of Error; RACE - Two or more races - White and '\n",
- " 'American Indian and Alaska Native',\n",
- " 'hc02_vc73': 'Margin of Error; RACE - Two or more races - White and Asian',\n",
- " 'hc02_vc74': 'Margin of Error; RACE - Two or more races - Black or African '\n",
- " 'American and American Indian and Alaska Native',\n",
- " 'hc02_vc77': 'Margin of Error; RACE - Race alone or in combination with one '\n",
- " 'or more other races - Total population',\n",
- " 'hc02_vc78': 'Margin of Error; RACE - Race alone or in combination with one '\n",
- " 'or more other races - Total population - White',\n",
- " 'hc02_vc79': 'Margin of Error; RACE - Race alone or in combination with one '\n",
- " 'or more other races - Total population - Black or African '\n",
- " 'American',\n",
- " 'hc02_vc80': 'Margin of Error; RACE - Race alone or in combination with one '\n",
- " 'or more other races - Total population - American Indian and '\n",
- " 'Alaska Native',\n",
- " 'hc02_vc81': 'Margin of Error; RACE - Race alone or in combination with one '\n",
- " 'or more other races - Total population - Asian',\n",
- " 'hc02_vc82': 'Margin of Error; RACE - Race alone or in combination with one '\n",
- " 'or more other races - Total population - Native Hawaiian and '\n",
- " 'Other Pacific Islander',\n",
- " 'hc02_vc83': 'Margin of Error; RACE - Race alone or in combination with one '\n",
- " 'or more other races - Total population - Some other race',\n",
- " 'hc02_vc87': 'Margin of Error; HISPANIC OR LATINO AND RACE - Total '\n",
- " 'population',\n",
- " 'hc02_vc88': 'Margin of Error; HISPANIC OR LATINO AND RACE - Total '\n",
- " 'population - Hispanic or Latino (of any race)',\n",
- " 'hc02_vc89': 'Margin of Error; HISPANIC OR LATINO AND RACE - Total '\n",
- " 'population - Hispanic or Latino (of any race) - Mexican',\n",
- " 'hc02_vc90': 'Margin of Error; HISPANIC OR LATINO AND RACE - Total '\n",
- " 'population - Hispanic or Latino (of any race) - Puerto Rican',\n",
- " 'hc02_vc91': 'Margin of Error; HISPANIC OR LATINO AND RACE - Total '\n",
- " 'population - Hispanic or Latino (of any race) - Cuban',\n",
- " 'hc02_vc92': 'Margin of Error; HISPANIC OR LATINO AND RACE - Total '\n",
- " 'population - Hispanic or Latino (of any race) - Other '\n",
- " 'Hispanic or Latino',\n",
- " 'hc02_vc93': 'Margin of Error; HISPANIC OR LATINO AND RACE - Total '\n",
- " 'population - Not Hispanic or Latino',\n",
- " 'hc02_vc94': 'Margin of Error; HISPANIC OR LATINO AND RACE - Total '\n",
- " 'population - Not Hispanic or Latino - White alone',\n",
- " 'hc02_vc95': 'Margin of Error; HISPANIC OR LATINO AND RACE - Total '\n",
- " 'population - Not Hispanic or Latino - Black or African '\n",
- " 'American alone',\n",
- " 'hc02_vc96': 'Margin of Error; HISPANIC OR LATINO AND RACE - Total '\n",
- " 'population - Not Hispanic or Latino - American Indian and '\n",
- " 'Alaska Native alone',\n",
- " 'hc02_vc97': 'Margin of Error; HISPANIC OR LATINO AND RACE - Total '\n",
- " 'population - Not Hispanic or Latino - Asian alone',\n",
- " 'hc02_vc98': 'Margin of Error; HISPANIC OR LATINO AND RACE - Total '\n",
- " 'population - Not Hispanic or Latino - Native Hawaiian and '\n",
- " 'Other Pacific Islander alone',\n",
- " 'hc02_vc99': 'Margin of Error; HISPANIC OR LATINO AND RACE - Total '\n",
- " 'population - Not Hispanic or Latino - Some other race alone',\n",
- " 'hc03_vc03': 'Percent; SEX AND AGE - Total population',\n",
- " 'hc03_vc04': 'Percent; SEX AND AGE - Total population - Male',\n",
- " 'hc03_vc05': 'Percent; SEX AND AGE - Total population - Female',\n",
- " 'hc03_vc08': 'Percent; SEX AND AGE - Under 5 years',\n",
- " 'hc03_vc09': 'Percent; SEX AND AGE - 5 to 9 years',\n",
- " 'hc03_vc10': 'Percent; SEX AND AGE - 10 to 14 years',\n",
- " 'hc03_vc100': 'Percent; HISPANIC OR LATINO AND RACE - Total population - '\n",
- " 'Not Hispanic or Latino - Two or more races',\n",
- " 'hc03_vc101': 'Percent; HISPANIC OR LATINO AND RACE - Total population - '\n",
- " 'Not Hispanic or Latino - Two or more races - Two races '\n",
- " 'including Some other race',\n",
- " 'hc03_vc102': 'Percent; HISPANIC OR LATINO AND RACE - Total population - '\n",
- " 'Not Hispanic or Latino - Two or more races - Two races '\n",
- " 'excluding Some other race, and Three or more races',\n",
- " 'hc03_vc104': 'Percent; HISPANIC OR LATINO AND RACE - Total housing units',\n",
- " 'hc03_vc11': 'Percent; SEX AND AGE - 15 to 19 years',\n",
- " 'hc03_vc12': 'Percent; SEX AND AGE - 20 to 24 years',\n",
- " 'hc03_vc13': 'Percent; SEX AND AGE - 25 to 34 years',\n",
- " 'hc03_vc14': 'Percent; SEX AND AGE - 35 to 44 years',\n",
- " 'hc03_vc15': 'Percent; SEX AND AGE - 45 to 54 years',\n",
- " 'hc03_vc16': 'Percent; SEX AND AGE - 55 to 59 years',\n",
- " 'hc03_vc17': 'Percent; SEX AND AGE - 60 to 64 years',\n",
- " 'hc03_vc18': 'Percent; SEX AND AGE - 65 to 74 years',\n",
- " 'hc03_vc19': 'Percent; SEX AND AGE - 75 to 84 years',\n",
- " 'hc03_vc20': 'Percent; SEX AND AGE - 85 years and over',\n",
- " 'hc03_vc23': 'Percent; SEX AND AGE - Median age (years)',\n",
- " 'hc03_vc26': 'Percent; SEX AND AGE - 18 years and over',\n",
- " 'hc03_vc27': 'Percent; SEX AND AGE - 21 years and over',\n",
- " 'hc03_vc28': 'Percent; SEX AND AGE - 62 years and over',\n",
- " 'hc03_vc29': 'Percent; SEX AND AGE - 65 years and over',\n",
- " 'hc03_vc32': 'Percent; SEX AND AGE - 18 years and over',\n",
- " 'hc03_vc33': 'Percent; SEX AND AGE - 18 years and over - Male',\n",
- " 'hc03_vc34': 'Percent; SEX AND AGE - 18 years and over - Female',\n",
- " 'hc03_vc37': 'Percent; SEX AND AGE - 65 years and over',\n",
- " 'hc03_vc38': 'Percent; SEX AND AGE - 65 years and over - Male',\n",
- " 'hc03_vc39': 'Percent; SEX AND AGE - 65 years and over - Female',\n",
- " 'hc03_vc43': 'Percent; RACE - Total population',\n",
- " 'hc03_vc44': 'Percent; RACE - Total population - One race',\n",
- " 'hc03_vc45': 'Percent; RACE - Total population - Two or more races',\n",
- " 'hc03_vc48': 'Percent; RACE - One race',\n",
- " 'hc03_vc49': 'Percent; RACE - One race - White',\n",
- " 'hc03_vc50': 'Percent; RACE - One race - Black or African American',\n",
- " 'hc03_vc51': 'Percent; RACE - One race - American Indian and Alaska Native',\n",
- " 'hc03_vc52': 'Percent; RACE - One race - American Indian and Alaska Native '\n",
- " '- Cherokee tribal grouping',\n",
- " 'hc03_vc53': 'Percent; RACE - One race - American Indian and Alaska Native '\n",
- " '- Chippewa tribal grouping',\n",
- " 'hc03_vc54': 'Percent; RACE - One race - American Indian and Alaska Native '\n",
- " '- Navajo tribal grouping',\n",
- " 'hc03_vc55': 'Percent; RACE - One race - American Indian and Alaska Native '\n",
- " '- Sioux tribal grouping',\n",
- " 'hc03_vc56': 'Percent; RACE - One race - Asian',\n",
- " 'hc03_vc57': 'Percent; RACE - One race - Asian - Asian Indian',\n",
- " 'hc03_vc58': 'Percent; RACE - One race - Asian - Chinese',\n",
- " 'hc03_vc59': 'Percent; RACE - One race - Asian - Filipino',\n",
- " 'hc03_vc60': 'Percent; RACE - One race - Asian - Japanese',\n",
- " 'hc03_vc61': 'Percent; RACE - One race - Asian - Korean',\n",
- " 'hc03_vc62': 'Percent; RACE - One race - Asian - Vietnamese',\n",
- " 'hc03_vc63': 'Percent; RACE - One race - Asian - Other Asian',\n",
- " 'hc03_vc64': 'Percent; RACE - One race - Native Hawaiian and Other Pacific '\n",
- " 'Islander',\n",
- " 'hc03_vc65': 'Percent; RACE - One race - Native Hawaiian and Other Pacific '\n",
- " 'Islander - Native Hawaiian',\n",
- " 'hc03_vc66': 'Percent; RACE - One race - Native Hawaiian and Other Pacific '\n",
- " 'Islander - Guamanian or Chamorro',\n",
- " 'hc03_vc67': 'Percent; RACE - One race - Native Hawaiian and Other Pacific '\n",
- " 'Islander - Samoan',\n",
- " 'hc03_vc68': 'Percent; RACE - One race - Native Hawaiian and Other Pacific '\n",
- " 'Islander - Other Pacific Islander',\n",
- " 'hc03_vc69': 'Percent; RACE - One race - Some other race',\n",
- " 'hc03_vc70': 'Percent; RACE - Two or more races',\n",
- " 'hc03_vc71': 'Percent; RACE - Two or more races - White and Black or '\n",
- " 'African American',\n",
- " 'hc03_vc72': 'Percent; RACE - Two or more races - White and American Indian '\n",
- " 'and Alaska Native',\n",
- " 'hc03_vc73': 'Percent; RACE - Two or more races - White and Asian',\n",
- " 'hc03_vc74': 'Percent; RACE - Two or more races - Black or African American '\n",
- " 'and American Indian and Alaska Native',\n",
- " 'hc03_vc77': 'Percent; RACE - Race alone or in combination with one or more '\n",
- " 'other races - Total population',\n",
- " 'hc03_vc78': 'Percent; RACE - Race alone or in combination with one or more '\n",
- " 'other races - Total population - White',\n",
- " 'hc03_vc79': 'Percent; RACE - Race alone or in combination with one or more '\n",
- " 'other races - Total population - Black or African American',\n",
- " 'hc03_vc80': 'Percent; RACE - Race alone or in combination with one or more '\n",
- " 'other races - Total population - American Indian and Alaska '\n",
- " 'Native',\n",
- " 'hc03_vc81': 'Percent; RACE - Race alone or in combination with one or more '\n",
- " 'other races - Total population - Asian',\n",
- " 'hc03_vc82': 'Percent; RACE - Race alone or in combination with one or more '\n",
- " 'other races - Total population - Native Hawaiian and Other '\n",
- " 'Pacific Islander',\n",
- " 'hc03_vc83': 'Percent; RACE - Race alone or in combination with one or more '\n",
- " 'other races - Total population - Some other race',\n",
- " 'hc03_vc87': 'Percent; HISPANIC OR LATINO AND RACE - Total population',\n",
- " 'hc03_vc88': 'Percent; HISPANIC OR LATINO AND RACE - Total population - '\n",
- " 'Hispanic or Latino (of any race)',\n",
- " 'hc03_vc89': 'Percent; HISPANIC OR LATINO AND RACE - Total population - '\n",
- " 'Hispanic or Latino (of any race) - Mexican',\n",
- " 'hc03_vc90': 'Percent; HISPANIC OR LATINO AND RACE - Total population - '\n",
- " 'Hispanic or Latino (of any race) - Puerto Rican',\n",
- " 'hc03_vc91': 'Percent; HISPANIC OR LATINO AND RACE - Total population - '\n",
- " 'Hispanic or Latino (of any race) - Cuban',\n",
- " 'hc03_vc92': 'Percent; HISPANIC OR LATINO AND RACE - Total population - '\n",
- " 'Hispanic or Latino (of any race) - Other Hispanic or Latino',\n",
- " 'hc03_vc93': 'Percent; HISPANIC OR LATINO AND RACE - Total population - Not '\n",
- " 'Hispanic or Latino',\n",
- " 'hc03_vc94': 'Percent; HISPANIC OR LATINO AND RACE - Total population - Not '\n",
- " 'Hispanic or Latino - White alone',\n",
- " 'hc03_vc95': 'Percent; HISPANIC OR LATINO AND RACE - Total population - Not '\n",
- " 'Hispanic or Latino - Black or African American alone',\n",
- " 'hc03_vc96': 'Percent; HISPANIC OR LATINO AND RACE - Total population - Not '\n",
- " 'Hispanic or Latino - American Indian and Alaska Native alone',\n",
- " 'hc03_vc97': 'Percent; HISPANIC OR LATINO AND RACE - Total population - Not '\n",
- " 'Hispanic or Latino - Asian alone',\n",
- " 'hc03_vc98': 'Percent; HISPANIC OR LATINO AND RACE - Total population - Not '\n",
- " 'Hispanic or Latino - Native Hawaiian and Other Pacific '\n",
- " 'Islander alone',\n",
- " 'hc03_vc99': 'Percent; HISPANIC OR LATINO AND RACE - Total population - Not '\n",
- " 'Hispanic or Latino - Some other race alone',\n",
- " 'hc04_vc03': 'Percent Margin of Error; SEX AND AGE - Total population',\n",
- " 'hc04_vc04': 'Percent Margin of Error; SEX AND AGE - Total population - Male',\n",
- " 'hc04_vc05': 'Percent Margin of Error; SEX AND AGE - Total population - '\n",
- " 'Female',\n",
- " 'hc04_vc08': 'Percent Margin of Error; SEX AND AGE - Under 5 years',\n",
- " 'hc04_vc09': 'Percent Margin of Error; SEX AND AGE - 5 to 9 years',\n",
- " 'hc04_vc10': 'Percent Margin of Error; SEX AND AGE - 10 to 14 years',\n",
- " 'hc04_vc100': 'Percent Margin of Error; HISPANIC OR LATINO AND RACE - Total '\n",
- " 'population - Not Hispanic or Latino - Two or more races',\n",
- " 'hc04_vc101': 'Percent Margin of Error; HISPANIC OR LATINO AND RACE - Total '\n",
- " 'population - Not Hispanic or Latino - Two or more races - '\n",
- " 'Two races including Some other race',\n",
- " 'hc04_vc102': 'Percent Margin of Error; HISPANIC OR LATINO AND RACE - Total '\n",
- " 'population - Not Hispanic or Latino - Two or more races - '\n",
- " 'Two races excluding Some other race, and Three or more races',\n",
- " 'hc04_vc104': 'Percent Margin of Error; HISPANIC OR LATINO AND RACE - Total '\n",
- " 'housing units',\n",
- " 'hc04_vc11': 'Percent Margin of Error; SEX AND AGE - 15 to 19 years',\n",
- " 'hc04_vc12': 'Percent Margin of Error; SEX AND AGE - 20 to 24 years',\n",
- " 'hc04_vc13': 'Percent Margin of Error; SEX AND AGE - 25 to 34 years',\n",
- " 'hc04_vc14': 'Percent Margin of Error; SEX AND AGE - 35 to 44 years',\n",
- " 'hc04_vc15': 'Percent Margin of Error; SEX AND AGE - 45 to 54 years',\n",
- " 'hc04_vc16': 'Percent Margin of Error; SEX AND AGE - 55 to 59 years',\n",
- " 'hc04_vc17': 'Percent Margin of Error; SEX AND AGE - 60 to 64 years',\n",
- " 'hc04_vc18': 'Percent Margin of Error; SEX AND AGE - 65 to 74 years',\n",
- " 'hc04_vc19': 'Percent Margin of Error; SEX AND AGE - 75 to 84 years',\n",
- " 'hc04_vc20': 'Percent Margin of Error; SEX AND AGE - 85 years and over',\n",
- " 'hc04_vc23': 'Percent Margin of Error; SEX AND AGE - Median age (years)',\n",
- " 'hc04_vc26': 'Percent Margin of Error; SEX AND AGE - 18 years and over',\n",
- " 'hc04_vc27': 'Percent Margin of Error; SEX AND AGE - 21 years and over',\n",
- " 'hc04_vc28': 'Percent Margin of Error; SEX AND AGE - 62 years and over',\n",
- " 'hc04_vc29': 'Percent Margin of Error; SEX AND AGE - 65 years and over',\n",
- " 'hc04_vc32': 'Percent Margin of Error; SEX AND AGE - 18 years and over',\n",
- " 'hc04_vc33': 'Percent Margin of Error; SEX AND AGE - 18 years and over - '\n",
- " 'Male',\n",
- " 'hc04_vc34': 'Percent Margin of Error; SEX AND AGE - 18 years and over - '\n",
- " 'Female',\n",
- " 'hc04_vc37': 'Percent Margin of Error; SEX AND AGE - 65 years and over',\n",
- " 'hc04_vc38': 'Percent Margin of Error; SEX AND AGE - 65 years and over - '\n",
- " 'Male',\n",
- " 'hc04_vc39': 'Percent Margin of Error; SEX AND AGE - 65 years and over - '\n",
- " 'Female',\n",
- " 'hc04_vc43': 'Percent Margin of Error; RACE - Total population',\n",
- " 'hc04_vc44': 'Percent Margin of Error; RACE - Total population - One race',\n",
- " 'hc04_vc45': 'Percent Margin of Error; RACE - Total population - Two or '\n",
- " 'more races',\n",
- " 'hc04_vc48': 'Percent Margin of Error; RACE - One race',\n",
- " 'hc04_vc49': 'Percent Margin of Error; RACE - One race - White',\n",
- " 'hc04_vc50': 'Percent Margin of Error; RACE - One race - Black or African '\n",
- " 'American',\n",
- " 'hc04_vc51': 'Percent Margin of Error; RACE - One race - American Indian '\n",
- " 'and Alaska Native',\n",
- " 'hc04_vc52': 'Percent Margin of Error; RACE - One race - American Indian '\n",
- " 'and Alaska Native - Cherokee tribal grouping',\n",
- " 'hc04_vc53': 'Percent Margin of Error; RACE - One race - American Indian '\n",
- " 'and Alaska Native - Chippewa tribal grouping',\n",
- " 'hc04_vc54': 'Percent Margin of Error; RACE - One race - American Indian '\n",
- " 'and Alaska Native - Navajo tribal grouping',\n",
- " 'hc04_vc55': 'Percent Margin of Error; RACE - One race - American Indian '\n",
- " 'and Alaska Native - Sioux tribal grouping',\n",
- " 'hc04_vc56': 'Percent Margin of Error; RACE - One race - Asian',\n",
- " 'hc04_vc57': 'Percent Margin of Error; RACE - One race - Asian - Asian '\n",
- " 'Indian',\n",
- " 'hc04_vc58': 'Percent Margin of Error; RACE - One race - Asian - Chinese',\n",
- " 'hc04_vc59': 'Percent Margin of Error; RACE - One race - Asian - Filipino',\n",
- " 'hc04_vc60': 'Percent Margin of Error; RACE - One race - Asian - Japanese',\n",
- " 'hc04_vc61': 'Percent Margin of Error; RACE - One race - Asian - Korean',\n",
- " 'hc04_vc62': 'Percent Margin of Error; RACE - One race - Asian - Vietnamese',\n",
- " 'hc04_vc63': 'Percent Margin of Error; RACE - One race - Asian - Other Asian',\n",
- " 'hc04_vc64': 'Percent Margin of Error; RACE - One race - Native Hawaiian '\n",
- " 'and Other Pacific Islander',\n",
- " 'hc04_vc65': 'Percent Margin of Error; RACE - One race - Native Hawaiian '\n",
- " 'and Other Pacific Islander - Native Hawaiian',\n",
- " 'hc04_vc66': 'Percent Margin of Error; RACE - One race - Native Hawaiian '\n",
- " 'and Other Pacific Islander - Guamanian or Chamorro',\n",
- " 'hc04_vc67': 'Percent Margin of Error; RACE - One race - Native Hawaiian '\n",
- " 'and Other Pacific Islander - Samoan',\n",
- " 'hc04_vc68': 'Percent Margin of Error; RACE - One race - Native Hawaiian '\n",
- " 'and Other Pacific Islander - Other Pacific Islander',\n",
- " 'hc04_vc69': 'Percent Margin of Error; RACE - One race - Some other race',\n",
- " 'hc04_vc70': 'Percent Margin of Error; RACE - Two or more races',\n",
- " 'hc04_vc71': 'Percent Margin of Error; RACE - Two or more races - White and '\n",
- " 'Black or African American',\n",
- " 'hc04_vc72': 'Percent Margin of Error; RACE - Two or more races - White and '\n",
- " 'American Indian and Alaska Native',\n",
- " 'hc04_vc73': 'Percent Margin of Error; RACE - Two or more races - White and '\n",
- " 'Asian',\n",
- " 'hc04_vc74': 'Percent Margin of Error; RACE - Two or more races - Black or '\n",
- " 'African American and American Indian and Alaska Native',\n",
- " 'hc04_vc77': 'Percent Margin of Error; RACE - Race alone or in combination '\n",
- " 'with one or more other races - Total population',\n",
- " 'hc04_vc78': 'Percent Margin of Error; RACE - Race alone or in combination '\n",
- " 'with one or more other races - Total population - White',\n",
- " 'hc04_vc79': 'Percent Margin of Error; RACE - Race alone or in combination '\n",
- " 'with one or more other races - Total population - Black or '\n",
- " 'African American',\n",
- " 'hc04_vc80': 'Percent Margin of Error; RACE - Race alone or in combination '\n",
- " 'with one or more other races - Total population - American '\n",
- " 'Indian and Alaska Native',\n",
- " 'hc04_vc81': 'Percent Margin of Error; RACE - Race alone or in combination '\n",
- " 'with one or more other races - Total population - Asian',\n",
- " 'hc04_vc82': 'Percent Margin of Error; RACE - Race alone or in combination '\n",
- " 'with one or more other races - Total population - Native '\n",
- " 'Hawaiian and Other Pacific Islander',\n",
- " 'hc04_vc83': 'Percent Margin of Error; RACE - Race alone or in combination '\n",
- " 'with one or more other races - Total population - Some other '\n",
- " 'race',\n",
- " 'hc04_vc87': 'Percent Margin of Error; HISPANIC OR LATINO AND RACE - Total '\n",
- " 'population',\n",
- " 'hc04_vc88': 'Percent Margin of Error; HISPANIC OR LATINO AND RACE - Total '\n",
- " 'population - Hispanic or Latino (of any race)',\n",
- " 'hc04_vc89': 'Percent Margin of Error; HISPANIC OR LATINO AND RACE - Total '\n",
- " 'population - Hispanic or Latino (of any race) - Mexican',\n",
- " 'hc04_vc90': 'Percent Margin of Error; HISPANIC OR LATINO AND RACE - Total '\n",
- " 'population - Hispanic or Latino (of any race) - Puerto Rican',\n",
- " 'hc04_vc91': 'Percent Margin of Error; HISPANIC OR LATINO AND RACE - Total '\n",
- " 'population - Hispanic or Latino (of any race) - Cuban',\n",
- " 'hc04_vc92': 'Percent Margin of Error; HISPANIC OR LATINO AND RACE - Total '\n",
- " 'population - Hispanic or Latino (of any race) - Other '\n",
- " 'Hispanic or Latino',\n",
- " 'hc04_vc93': 'Percent Margin of Error; HISPANIC OR LATINO AND RACE - Total '\n",
- " 'population - Not Hispanic or Latino',\n",
- " 'hc04_vc94': 'Percent Margin of Error; HISPANIC OR LATINO AND RACE - Total '\n",
- " 'population - Not Hispanic or Latino - White alone',\n",
- " 'hc04_vc95': 'Percent Margin of Error; HISPANIC OR LATINO AND RACE - Total '\n",
- " 'population - Not Hispanic or Latino - Black or African '\n",
- " 'American alone',\n",
- " 'hc04_vc96': 'Percent Margin of Error; HISPANIC OR LATINO AND RACE - Total '\n",
- " 'population - Not Hispanic or Latino - American Indian and '\n",
- " 'Alaska Native alone',\n",
- " 'hc04_vc97': 'Percent Margin of Error; HISPANIC OR LATINO AND RACE - Total '\n",
- " 'population - Not Hispanic or Latino - Asian alone',\n",
- " 'hc04_vc98': 'Percent Margin of Error; HISPANIC OR LATINO AND RACE - Total '\n",
- " 'population - Not Hispanic or Latino - Native Hawaiian and '\n",
- " 'Other Pacific Islander alone',\n",
- " 'hc04_vc99': 'Percent Margin of Error; HISPANIC OR LATINO AND RACE - Total '\n",
- " 'population - Not Hispanic or Latino - Some other race alone'}\n"
+ "Metadata:\n"
]
},
{
@@ -791,30 +230,44 @@
" geo_id2 | \n",
" Id2 | \n",
" \n",
+ " \n",
+ " 2 | \n",
+ " geo_display_label | \n",
+ " Geography | \n",
+ "
\n",
+ " \n",
+ " 3 | \n",
+ " hc01_vc03 | \n",
+ " Estimate; HOUSEHOLDS BY TYPE - Total households | \n",
+ "
\n",
" \n",
"\n",
""
],
"text/plain": [
- " data_column_name description\n",
- "0 geo_id Id\n",
- "1 geo_id2 Id2"
+ " data_column_name description\n",
+ "0 geo_id Id\n",
+ "1 geo_id2 Id2\n",
+ "2 geo_display_label Geography\n",
+ "3 hc01_vc03 Estimate; HOUSEHOLDS BY TYPE - Total households"
]
},
- "execution_count": 86,
+ "execution_count": 290,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
- "print('data dictionary')\n",
- "pprint(data_dictionary)\n",
- "df_meta.head(n=2)"
+ "# print('data dictionary')\n",
+ "# pprint(data_dictionary)\n",
+ "\n",
+ "print('Metadata:')\n",
+ "df_meta.head(n=4)"
]
},
{
"cell_type": "code",
- "execution_count": 76,
+ "execution_count": 254,
"metadata": {
"collapsed": false
},
@@ -845,16 +298,16 @@
" hc02_vc04 | \n",
" hc03_vc04 | \n",
" ... | \n",
- " hc03_vc101 | \n",
- " hc04_vc101 | \n",
- " hc01_vc102 | \n",
- " hc02_vc102 | \n",
- " hc03_vc102 | \n",
- " hc04_vc102 | \n",
- " hc01_vc104 | \n",
- " hc02_vc104 | \n",
- " hc03_vc104 | \n",
- " hc04_vc104 | \n",
+ " hc03_vc216 | \n",
+ " hc04_vc216 | \n",
+ " hc01_vc217 | \n",
+ " hc02_vc217 | \n",
+ " hc03_vc217 | \n",
+ " hc04_vc217 | \n",
+ " hc01_vc218 | \n",
+ " hc02_vc218 | \n",
+ " hc03_vc218 | \n",
+ " hc04_vc218 | \n",
" \n",
" \n",
" \n",
@@ -863,22 +316,22 @@
" 1400000US06075010100 | \n",
" 06075010100 | \n",
" Census Tract 101, San Francisco County, Califo... | \n",
- " 3741 | \n",
- " 358 | \n",
- " 3741 | \n",
+ " 2177 | \n",
+ " 126 | \n",
+ " 2177 | \n",
" (X) | \n",
- " 2051 | \n",
- " 343 | \n",
- " 54.8 | \n",
+ " 603 | \n",
+ " 137 | \n",
+ " 27.7 | \n",
" ... | \n",
- " 1.4 | \n",
- " 2.1 | \n",
- " 192 | \n",
- " 177 | \n",
- " 5.1 | \n",
- " 4.7 | \n",
- " 2306 | \n",
- " 84 | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
" (X) | \n",
" (X) | \n",
" \n",
@@ -887,28 +340,28 @@
" 1400000US06075010200 | \n",
" 06075010200 | \n",
" Census Tract 102, San Francisco County, Califo... | \n",
- " 4028 | \n",
- " 325 | \n",
- " 4028 | \n",
+ " 2547 | \n",
+ " 186 | \n",
+ " 2547 | \n",
" (X) | \n",
- " 2017 | \n",
- " 213 | \n",
- " 50.1 | \n",
+ " 677 | \n",
+ " 136 | \n",
+ " 26.6 | \n",
" ... | \n",
- " 0.0 | \n",
- " 0.9 | \n",
- " 137 | \n",
- " 93 | \n",
- " 3.4 | \n",
- " 2.3 | \n",
- " 2948 | \n",
- " 108 | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
" (X) | \n",
" (X) | \n",
" \n",
" \n",
"\n",
- "2 rows × 327 columns
\n",
+ "2 rows × 611 columns
\n",
""
],
"text/plain": [
@@ -917,25 +370,25 @@
"2 1400000US06075010200 06075010200 \n",
"\n",
" geo_display_label hc01_vc03 hc02_vc03 \\\n",
- "1 Census Tract 101, San Francisco County, Califo... 3741 358 \n",
- "2 Census Tract 102, San Francisco County, Califo... 4028 325 \n",
+ "1 Census Tract 101, San Francisco County, Califo... 2177 126 \n",
+ "2 Census Tract 102, San Francisco County, Califo... 2547 186 \n",
"\n",
- " hc03_vc03 hc04_vc03 hc01_vc04 hc02_vc04 hc03_vc04 ... hc03_vc101 \\\n",
- "1 3741 (X) 2051 343 54.8 ... 1.4 \n",
- "2 4028 (X) 2017 213 50.1 ... 0.0 \n",
+ " hc03_vc03 hc04_vc03 hc01_vc04 hc02_vc04 hc03_vc04 ... hc03_vc216 \\\n",
+ "1 2177 (X) 603 137 27.7 ... (X) \n",
+ "2 2547 (X) 677 136 26.6 ... (X) \n",
"\n",
- " hc04_vc101 hc01_vc102 hc02_vc102 hc03_vc102 hc04_vc102 hc01_vc104 \\\n",
- "1 2.1 192 177 5.1 4.7 2306 \n",
- "2 0.9 137 93 3.4 2.3 2948 \n",
+ " hc04_vc216 hc01_vc217 hc02_vc217 hc03_vc217 hc04_vc217 hc01_vc218 \\\n",
+ "1 (X) (X) (X) (X) (X) (X) \n",
+ "2 (X) (X) (X) (X) (X) (X) \n",
"\n",
- " hc02_vc104 hc03_vc104 hc04_vc104 \n",
- "1 84 (X) (X) \n",
- "2 108 (X) (X) \n",
+ " hc02_vc218 hc03_vc218 hc04_vc218 \n",
+ "1 (X) (X) (X) \n",
+ "2 (X) (X) (X) \n",
"\n",
- "[2 rows x 327 columns]"
+ "[2 rows x 611 columns]"
]
},
- "execution_count": 76,
+ "execution_count": 254,
"metadata": {},
"output_type": "execute_result"
}
@@ -954,528 +407,397 @@
},
{
"cell_type": "code",
- "execution_count": 67,
- "metadata": {
- "collapsed": true
- },
- "outputs": [],
- "source": [
- "# Visualize each column (e.g., empricial distrbutions)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 87,
+ "execution_count": 256,
"metadata": {
"collapsed": false
},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " data_column_name | \n",
+ " description | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " 363 | \n",
+ " hc01_vc135 | \n",
+ " Estimate; PLACE OF BIRTH - Total population - ... | \n",
+ "
\n",
+ " \n",
+ " 364 | \n",
+ " hc02_vc135 | \n",
+ " Margin of Error; PLACE OF BIRTH - Total popula... | \n",
+ "
\n",
+ " \n",
+ " 365 | \n",
+ " hc03_vc135 | \n",
+ " Percent; PLACE OF BIRTH - Total population - N... | \n",
+ "
\n",
+ " \n",
+ " 366 | \n",
+ " hc04_vc135 | \n",
+ " Percent Margin of Error; PLACE OF BIRTH - Tota... | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " data_column_name description\n",
+ "363 hc01_vc135 Estimate; PLACE OF BIRTH - Total population - ...\n",
+ "364 hc02_vc135 Margin of Error; PLACE OF BIRTH - Total popula...\n",
+ "365 hc03_vc135 Percent; PLACE OF BIRTH - Total population - N...\n",
+ "366 hc04_vc135 Percent Margin of Error; PLACE OF BIRTH - Tota..."
+ ]
+ },
+ "execution_count": 256,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
- "# Calculate summary stats (e.g., range, min, max)\n",
- "# df_data.geo_id2.nunique()\n",
+ "# Find columns that have name\n",
+ "# phrase = 'Percent Margin of Error; SEX AND AGE - Total population - Female'\n",
+ "phrase = 'Born in Puerto Rico'\n",
"\n",
- "# df_data.hc01_vc29.describe().T"
+ "df_selected = df_meta[df_meta.description.str.contains(phrase)]\n",
+ "df_selected"
]
},
{
"cell_type": "code",
- "execution_count": 88,
- "metadata": {
- "collapsed": false
- },
- "outputs": [],
- "source": [
- "# Filter / reduce data\n",
- "# Define these groups:\n",
- "# ACS_13_5YR_DP02_metadata\n",
- "# Total households\n",
- "# Families with children \n",
- "# Under 12\n",
- "# 12 to 18\n",
- "# 19 to 64\n",
- "# 65 and over\n",
- "# Single Parents\n",
- "# Under 12\n",
- "# 12 to 18\n",
- "# 19 to 64\n",
- "# 65 and over\n",
- "# Average family size\n",
- "# Estimate; HOUSEHOLDS BY TYPE - Average family size\n",
- "# Educational Attainment\n",
- "# No Educational Attainment\n",
- "# High School\n",
- "# Collect\n",
- "# Master and Beyond\n",
- "# Disability\n",
- "# Percent; DISABILITY STATUS OF THE CIVILIAN NONINSTITUTIONALIZED POPULATION - 18 to 64 years\n",
- "# Percent; PLACE OF BIRTH - Total population - Native"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 95,
+ "execution_count": 309,
"metadata": {
"collapsed": false
},
"outputs": [
{
- "ename": "KeyError",
- "evalue": "'hc05_vc03'",
- "output_type": "error",
- "traceback": [
- "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
- "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)",
- "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;31m#Estimate; HOUSEHOLDS BY TYPE - Total households\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mdata_dictionary\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'hc05_vc03'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
- "\u001b[0;31mKeyError\u001b[0m: 'hc05_vc03'"
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Column key: \thc01_vc216\n",
+ "\n",
+ "Statistic type: Estimate\n",
+ "\n",
+ "Statistic descriptions: \n",
+ "\t Computers And Internet Use \n",
+ "\t Total Households\n",
+ "\n",
+ "--------------------------------------------------------------------------------\n",
+ "\n",
+ "Column key: \thc02_vc216\n",
+ "\n",
+ "Statistic type: Margin of Error\n",
+ "\n",
+ "Statistic descriptions: \n",
+ "\t Computers And Internet Use \n",
+ "\t Total Households\n",
+ "\n",
+ "--------------------------------------------------------------------------------\n",
+ "\n",
+ "Column key: \thc03_vc216\n",
+ "\n",
+ "Statistic type: Percent\n",
+ "\n",
+ "Statistic descriptions: \n",
+ "\t Computers And Internet Use \n",
+ "\t Total Households\n",
+ "\n",
+ "--------------------------------------------------------------------------------\n",
+ "\n",
+ "Column key: \thc04_vc216\n",
+ "\n",
+ "Statistic type: Percent Margin of Error\n",
+ "\n",
+ "Statistic descriptions: \n",
+ "\t Computers And Internet Use \n",
+ "\t Total Households\n",
+ "\n",
+ "--------------------------------------------------------------------------------\n",
+ "\n",
+ "Column key: \thc01_vc217\n",
+ "\n",
+ "Statistic type: Estimate\n",
+ "\n",
+ "Statistic descriptions: \n",
+ "\t Computers And Internet Use \n",
+ "\t Total Households \n",
+ "\t With A Computer\n",
+ "\n",
+ "--------------------------------------------------------------------------------\n",
+ "\n",
+ "Column key: \thc02_vc217\n",
+ "\n",
+ "Statistic type: Margin of Error\n",
+ "\n",
+ "Statistic descriptions: \n",
+ "\t Computers And Internet Use \n",
+ "\t Total Households \n",
+ "\t With A Computer\n",
+ "\n",
+ "--------------------------------------------------------------------------------\n",
+ "\n",
+ "Column key: \thc03_vc217\n",
+ "\n",
+ "Statistic type: Percent\n",
+ "\n",
+ "Statistic descriptions: \n",
+ "\t Computers And Internet Use \n",
+ "\t Total Households \n",
+ "\t With A Computer\n",
+ "\n",
+ "--------------------------------------------------------------------------------\n",
+ "\n",
+ "Column key: \thc04_vc217\n",
+ "\n",
+ "Statistic type: Percent Margin of Error\n",
+ "\n",
+ "Statistic descriptions: \n",
+ "\t Computers And Internet Use \n",
+ "\t Total Households \n",
+ "\t With A Computer\n",
+ "\n",
+ "--------------------------------------------------------------------------------\n",
+ "\n",
+ "Column key: \thc01_vc218\n",
+ "\n",
+ "Statistic type: Estimate\n",
+ "\n",
+ "Statistic descriptions: \n",
+ "\t Computers And Internet Use \n",
+ "\t Total Households \n",
+ "\t With A Broadband Internet Subscription\n",
+ "\n",
+ "--------------------------------------------------------------------------------\n",
+ "\n",
+ "Column key: \thc02_vc218\n",
+ "\n",
+ "Statistic type: Margin of Error\n",
+ "\n",
+ "Statistic descriptions: \n",
+ "\t Computers And Internet Use \n",
+ "\t Total Households \n",
+ "\t With A Broadband Internet Subscription\n",
+ "\n",
+ "--------------------------------------------------------------------------------\n",
+ "\n",
+ "Column key: \thc03_vc218\n",
+ "\n",
+ "Statistic type: Percent\n",
+ "\n",
+ "Statistic descriptions: \n",
+ "\t Computers And Internet Use \n",
+ "\t Total Households \n",
+ "\t With A Broadband Internet Subscription\n",
+ "\n",
+ "--------------------------------------------------------------------------------\n",
+ "\n",
+ "Column key: \thc04_vc218\n",
+ "\n",
+ "Statistic type: Percent Margin of Error\n",
+ "\n",
+ "Statistic descriptions: \n",
+ "\t Computers And Internet Use \n",
+ "\t Total Households \n",
+ "\t With A Broadband Internet Subscription\n",
+ "\n",
+ "--------------------------------------------------------------------------------\n",
+ "\n"
]
}
],
"source": [
- "#Estimate; HOUSEHOLDS BY TYPE - Total households\n",
- "data_dictionary['hc05_vc03']"
+ "# Print the information\n",
+ "for key, value in df_selected.values:\n",
+ " \n",
+ " print(\"Column key: \\t{}\\n\".format(key, value))\n",
+ " statistic_type, statistics_descriptions = value.split(\";\")\n",
+ " \n",
+ " print(\"Statistic type: {}\\n\".format(statistic_type))\n",
+ " print(\"Statistic descriptions: \")\n",
+ " \n",
+ " for statistic_description in statistics_descriptions.split(\"-\"):\n",
+ " print(\"\\t\"+statistic_description.title())\n",
+ " print(\"\\n\"+\"-\"*80+\"\\n\")"
]
},
{
"cell_type": "code",
- "execution_count": 108,
+ "execution_count": 310,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
+ "text/html": [
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " geo_display_label | \n",
+ " hc01_vc216 | \n",
+ " hc02_vc216 | \n",
+ " hc03_vc216 | \n",
+ " hc04_vc216 | \n",
+ " hc01_vc217 | \n",
+ " hc02_vc217 | \n",
+ " hc03_vc217 | \n",
+ " hc04_vc217 | \n",
+ " hc01_vc218 | \n",
+ " hc02_vc218 | \n",
+ " hc03_vc218 | \n",
+ " hc04_vc218 | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " 1 | \n",
+ " Census Tract 101, San Francisco County, Califo... | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ "
\n",
+ " \n",
+ " 2 | \n",
+ " Census Tract 102, San Francisco County, Califo... | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ "
\n",
+ " \n",
+ " 3 | \n",
+ " Census Tract 103, San Francisco County, Califo... | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ "
\n",
+ " \n",
+ " 4 | \n",
+ " Census Tract 104, San Francisco County, Califo... | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ "
\n",
+ " \n",
+ " 5 | \n",
+ " Census Tract 105, San Francisco County, Califo... | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ " (X) | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
"text/plain": [
- "['Margin of Error; RACE - One race - Native Hawaiian and Other Pacific Islander',\n",
- " 'Estimate; SEX AND AGE - Under 5 years',\n",
- " 'Margin of Error; RACE - One race - White',\n",
- " 'Percent; RACE - One race - Asian - Filipino',\n",
- " 'Estimate; SEX AND AGE - 21 years and over',\n",
- " 'Estimate; SEX AND AGE - Median age (years)',\n",
- " 'Estimate; RACE - Two or more races - White and Asian',\n",
- " 'Margin of Error; SEX AND AGE - 65 years and over - Female',\n",
- " 'Margin of Error; SEX AND AGE - Under 5 years',\n",
- " 'Margin of Error; RACE - One race - Native Hawaiian and Other Pacific Islander - Native Hawaiian',\n",
- " 'Margin of Error; SEX AND AGE - 21 years and over',\n",
- " 'Estimate; SEX AND AGE - 5 to 9 years',\n",
- " 'Percent; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - White alone',\n",
- " 'Percent Margin of Error; RACE - One race',\n",
- " 'Estimate; HISPANIC OR LATINO AND RACE - Total population - Hispanic or Latino (of any race) - Cuban',\n",
- " 'Margin of Error; RACE - Race alone or in combination with one or more other races - Total population - Some other race',\n",
- " 'Percent Margin of Error; HISPANIC OR LATINO AND RACE - Total population',\n",
- " 'Percent; SEX AND AGE - 75 to 84 years',\n",
- " 'Percent Margin of Error; RACE - One race - White',\n",
- " 'Percent Margin of Error; RACE - One race - Asian - Japanese',\n",
- " 'Estimate; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Black or African American alone',\n",
- " 'Margin of Error; RACE - One race - Asian - Japanese',\n",
- " 'Estimate; HISPANIC OR LATINO AND RACE - Total population - Hispanic or Latino (of any race)',\n",
- " 'Percent Margin of Error; RACE - One race - Asian - Other Asian',\n",
- " 'Percent; RACE - One race - American Indian and Alaska Native - Chippewa tribal grouping',\n",
- " 'Percent Margin of Error; RACE - One race - Asian',\n",
- " 'Margin of Error; RACE - One race - Asian - Vietnamese',\n",
- " 'Margin of Error; SEX AND AGE - Median age (years)',\n",
- " 'Percent; SEX AND AGE - 65 years and over',\n",
- " 'Estimate; RACE - Two or more races - White and Black or African American',\n",
- " 'Margin of Error; SEX AND AGE - 75 to 84 years',\n",
- " 'Percent Margin of Error; SEX AND AGE - 5 to 9 years',\n",
- " 'Percent Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Two or more races - Two races excluding Some other race, and Three or more races',\n",
- " 'Estimate; SEX AND AGE - Total population - Female',\n",
- " 'Percent Margin of Error; RACE - Total population - Two or more races',\n",
- " 'Percent Margin of Error; SEX AND AGE - 20 to 24 years',\n",
- " 'Percent; RACE - One race - Some other race',\n",
- " 'Percent Margin of Error; SEX AND AGE - 85 years and over',\n",
- " 'Percent Margin of Error; SEX AND AGE - Under 5 years',\n",
- " 'Percent Margin of Error; RACE - Race alone or in combination with one or more other races - Total population - Native Hawaiian and Other Pacific Islander',\n",
- " 'Estimate; RACE - Two or more races - White and American Indian and Alaska Native',\n",
- " 'Percent; SEX AND AGE - Total population',\n",
- " 'Percent Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Black or African American alone',\n",
- " 'Percent Margin of Error; RACE - One race - Native Hawaiian and Other Pacific Islander - Samoan',\n",
- " 'Percent; HISPANIC OR LATINO AND RACE - Total population',\n",
- " 'Margin of Error; RACE - One race - Asian - Asian Indian',\n",
- " 'Estimate; RACE - Total population',\n",
- " 'Estimate; RACE - One race - Native Hawaiian and Other Pacific Islander - Guamanian or Chamorro',\n",
- " 'Margin of Error; RACE - One race - Asian - Korean',\n",
- " 'Id2',\n",
- " 'Estimate; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Some other race alone',\n",
- " 'Percent; SEX AND AGE - 25 to 34 years',\n",
- " 'Percent; SEX AND AGE - 35 to 44 years',\n",
- " 'Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Two or more races - Two races including Some other race',\n",
- " 'Estimate; HISPANIC OR LATINO AND RACE - Total population - Hispanic or Latino (of any race) - Other Hispanic or Latino',\n",
- " 'Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Hispanic or Latino (of any race) - Other Hispanic or Latino',\n",
- " 'Percent Margin of Error; RACE - One race - American Indian and Alaska Native - Sioux tribal grouping',\n",
- " 'Percent; RACE - Total population - Two or more races',\n",
- " 'Margin of Error; RACE - Race alone or in combination with one or more other races - Total population - Asian',\n",
- " 'Margin of Error; RACE - Race alone or in combination with one or more other races - Total population',\n",
- " 'Percent Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Hispanic or Latino (of any race) - Cuban',\n",
- " 'Percent; SEX AND AGE - 18 years and over - Female',\n",
- " 'Margin of Error; RACE - Race alone or in combination with one or more other races - Total population - White',\n",
- " 'Percent Margin of Error; RACE - One race - Asian - Asian Indian',\n",
- " 'Percent; RACE - One race - Asian - Other Asian',\n",
- " 'Percent Margin of Error; RACE - One race - American Indian and Alaska Native - Cherokee tribal grouping',\n",
- " 'Margin of Error; RACE - One race - Asian',\n",
- " 'Percent; HISPANIC OR LATINO AND RACE - Total population - Hispanic or Latino (of any race) - Mexican',\n",
- " 'Percent Margin of Error; SEX AND AGE - 60 to 64 years',\n",
- " 'Estimate; RACE - Two or more races',\n",
- " 'Percent; SEX AND AGE - 15 to 19 years',\n",
- " 'Percent Margin of Error; SEX AND AGE - Total population',\n",
- " 'Percent Margin of Error; RACE - One race - Asian - Chinese',\n",
- " 'Margin of Error; SEX AND AGE - 10 to 14 years',\n",
- " 'Margin of Error; RACE - Total population - One race',\n",
- " 'Percent Margin of Error; SEX AND AGE - 75 to 84 years',\n",
- " 'Estimate; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - White alone',\n",
- " 'Percent; RACE - One race - Asian',\n",
- " 'Percent Margin of Error; SEX AND AGE - 25 to 34 years',\n",
- " 'Percent Margin of Error; RACE - One race - American Indian and Alaska Native',\n",
- " 'Percent; SEX AND AGE - 10 to 14 years',\n",
- " 'Estimate; RACE - One race - Native Hawaiian and Other Pacific Islander - Samoan',\n",
- " 'Percent; RACE - Race alone or in combination with one or more other races - Total population - White',\n",
- " 'Percent Margin of Error; SEX AND AGE - 65 years and over',\n",
- " 'Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Two or more races',\n",
- " 'Estimate; SEX AND AGE - 65 years and over - Female',\n",
- " 'Estimate; SEX AND AGE - 62 years and over',\n",
- " 'Estimate; RACE - Total population - One race',\n",
- " 'Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Some other race alone',\n",
- " 'Percent; RACE - One race - American Indian and Alaska Native',\n",
- " 'Estimate; SEX AND AGE - 65 to 74 years',\n",
- " 'Percent; RACE - One race - Asian - Japanese',\n",
- " 'Percent Margin of Error; SEX AND AGE - 21 years and over',\n",
- " 'Percent Margin of Error; SEX AND AGE - 35 to 44 years',\n",
- " 'Estimate; RACE - One race - Asian - Asian Indian',\n",
- " 'Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Black or African American alone',\n",
- " 'Percent Margin of Error; RACE - Race alone or in combination with one or more other races - Total population - Black or African American',\n",
- " 'Margin of Error; RACE - One race - Black or African American',\n",
- " 'Margin of Error; SEX AND AGE - 65 to 74 years',\n",
- " 'Percent; SEX AND AGE - 65 years and over - Male',\n",
- " 'Percent Margin of Error; RACE - One race - Some other race',\n",
- " 'Margin of Error; RACE - One race - Asian - Other Asian',\n",
- " 'Margin of Error; RACE - One race - Native Hawaiian and Other Pacific Islander - Samoan',\n",
- " 'Percent Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Two or more races',\n",
- " 'Percent Margin of Error; RACE - Two or more races - White and Black or African American',\n",
- " 'Id',\n",
- " 'Margin of Error; SEX AND AGE - 60 to 64 years',\n",
- " 'Percent Margin of Error; RACE - Race alone or in combination with one or more other races - Total population - White',\n",
- " 'Percent Margin of Error; SEX AND AGE - Median age (years)',\n",
- " 'Margin of Error; SEX AND AGE - 65 years and over',\n",
- " 'Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Hispanic or Latino (of any race) - Cuban',\n",
- " 'Percent Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Asian alone',\n",
- " 'Percent; RACE - Two or more races',\n",
- " 'Percent; RACE - One race - White',\n",
- " 'Percent; SEX AND AGE - 65 years and over',\n",
- " 'Margin of Error; RACE - Total population - Two or more races',\n",
- " 'Estimate; RACE - One race - Asian - Filipino',\n",
- " 'Percent Margin of Error; SEX AND AGE - 18 years and over - Male',\n",
- " 'Estimate; SEX AND AGE - 18 years and over',\n",
- " 'Percent; HISPANIC OR LATINO AND RACE - Total population - Hispanic or Latino (of any race) - Other Hispanic or Latino',\n",
- " 'Percent Margin of Error; RACE - One race - American Indian and Alaska Native - Navajo tribal grouping',\n",
- " 'Percent; RACE - Race alone or in combination with one or more other races - Total population',\n",
- " 'Percent Margin of Error; RACE - Race alone or in combination with one or more other races - Total population - Asian',\n",
- " 'Margin of Error; SEX AND AGE - 18 years and over - Male',\n",
- " 'Margin of Error; SEX AND AGE - 18 years and over - Female',\n",
- " 'Margin of Error; SEX AND AGE - 35 to 44 years',\n",
- " 'Percent; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Two or more races - Two races excluding Some other race, and Three or more races',\n",
- " 'Estimate; RACE - Race alone or in combination with one or more other races - Total population - American Indian and Alaska Native',\n",
- " 'Percent; RACE - Race alone or in combination with one or more other races - Total population - Asian',\n",
- " 'Percent Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino',\n",
- " 'Margin of Error; RACE - Two or more races',\n",
- " 'Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino',\n",
- " 'Estimate; RACE - One race - American Indian and Alaska Native',\n",
- " 'Percent Margin of Error; SEX AND AGE - Total population - Female',\n",
- " 'Estimate; SEX AND AGE - 65 years and over',\n",
- " 'Percent; RACE - Total population',\n",
- " 'Margin of Error; SEX AND AGE - Total population - Male',\n",
- " 'Percent; RACE - Two or more races - Black or African American and American Indian and Alaska Native',\n",
- " 'Percent; SEX AND AGE - 20 to 24 years',\n",
- " 'Margin of Error; SEX AND AGE - 18 years and over',\n",
- " 'Margin of Error; RACE - Two or more races - Black or African American and American Indian and Alaska Native',\n",
- " 'Percent; RACE - One race - American Indian and Alaska Native - Cherokee tribal grouping',\n",
- " 'Estimate; RACE - Race alone or in combination with one or more other races - Total population - Native Hawaiian and Other Pacific Islander',\n",
- " 'Percent; HISPANIC OR LATINO AND RACE - Total population - Hispanic or Latino (of any race) - Cuban',\n",
- " 'Percent; HISPANIC OR LATINO AND RACE - Total housing units',\n",
- " 'Estimate; HISPANIC OR LATINO AND RACE - Total population - Hispanic or Latino (of any race) - Mexican',\n",
- " 'Estimate; RACE - One race - Native Hawaiian and Other Pacific Islander',\n",
- " 'Percent Margin of Error; RACE - One race - Native Hawaiian and Other Pacific Islander - Native Hawaiian',\n",
- " 'Margin of Error; SEX AND AGE - 85 years and over',\n",
- " 'Percent Margin of Error; RACE - One race - Black or African American',\n",
- " 'Margin of Error; RACE - Two or more races - White and Black or African American',\n",
- " 'Percent Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Hispanic or Latino (of any race) - Other Hispanic or Latino',\n",
- " 'Percent; RACE - One race - Asian - Vietnamese',\n",
- " 'Percent Margin of Error; SEX AND AGE - 65 years and over - Male',\n",
- " 'Percent Margin of Error; SEX AND AGE - Total population - Male',\n",
- " 'Percent; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Two or more races - Two races including Some other race',\n",
- " 'Estimate; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Two or more races - Two races including Some other race',\n",
- " 'Estimate; SEX AND AGE - 35 to 44 years',\n",
- " 'Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Hispanic or Latino (of any race) - Mexican',\n",
- " 'Estimate; SEX AND AGE - Total population',\n",
- " 'Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Native Hawaiian and Other Pacific Islander alone',\n",
- " 'Margin of Error; RACE - One race - Asian - Filipino',\n",
- " 'Percent Margin of Error; RACE - One race - Asian - Filipino',\n",
- " 'Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Hispanic or Latino (of any race) - Puerto Rican',\n",
- " 'Estimate; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - American Indian and Alaska Native alone',\n",
- " 'Percent; HISPANIC OR LATINO AND RACE - Total population - Hispanic or Latino (of any race) - Puerto Rican',\n",
- " 'Margin of Error; RACE - Race alone or in combination with one or more other races - Total population - Native Hawaiian and Other Pacific Islander',\n",
- " 'Percent; SEX AND AGE - Total population - Female',\n",
- " 'Margin of Error; RACE - One race - American Indian and Alaska Native - Sioux tribal grouping',\n",
- " 'Percent Margin of Error; RACE - Race alone or in combination with one or more other races - Total population - Some other race',\n",
- " 'Percent Margin of Error; SEX AND AGE - 62 years and over',\n",
- " 'Estimate; RACE - Race alone or in combination with one or more other races - Total population - Some other race',\n",
- " 'Percent Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Some other race alone',\n",
- " 'Percent; SEX AND AGE - 5 to 9 years',\n",
- " 'Margin of Error; SEX AND AGE - 65 years and over - Male',\n",
- " 'Estimate; SEX AND AGE - 10 to 14 years',\n",
- " 'Percent; SEX AND AGE - 60 to 64 years',\n",
- " 'Estimate; RACE - One race - White',\n",
- " 'Estimate; RACE - One race - Asian - Chinese',\n",
- " 'Estimate; RACE - One race - Native Hawaiian and Other Pacific Islander - Other Pacific Islander',\n",
- " 'Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Asian alone',\n",
- " 'Estimate; RACE - One race - American Indian and Alaska Native - Navajo tribal grouping',\n",
- " 'Margin of Error; SEX AND AGE - 62 years and over',\n",
- " 'Percent; RACE - One race - Native Hawaiian and Other Pacific Islander',\n",
- " 'Estimate; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino',\n",
- " 'Percent Margin of Error; RACE - Two or more races - White and Asian',\n",
- " 'Margin of Error; RACE - Race alone or in combination with one or more other races - Total population - Black or African American',\n",
- " 'Estimate; RACE - One race - American Indian and Alaska Native - Sioux tribal grouping',\n",
- " 'Percent Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Hispanic or Latino (of any race) - Puerto Rican',\n",
- " 'Estimate; HISPANIC OR LATINO AND RACE - Total population - Hispanic or Latino (of any race) - Puerto Rican',\n",
- " 'Estimate; RACE - One race - Asian',\n",
- " 'Estimate; SEX AND AGE - 25 to 34 years',\n",
- " 'Percent Margin of Error; SEX AND AGE - 65 to 74 years',\n",
- " 'Percent; RACE - One race - Native Hawaiian and Other Pacific Islander - Other Pacific Islander',\n",
- " 'Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - American Indian and Alaska Native alone',\n",
- " 'Percent; RACE - One race',\n",
- " 'Estimate; SEX AND AGE - 60 to 64 years',\n",
- " 'Estimate; SEX AND AGE - 65 years and over',\n",
- " 'Percent; SEX AND AGE - 18 years and over',\n",
- " 'Estimate; RACE - Race alone or in combination with one or more other races - Total population',\n",
- " 'Percent Margin of Error; RACE - Two or more races',\n",
- " 'Estimate; HISPANIC OR LATINO AND RACE - Total population',\n",
- " 'Estimate; SEX AND AGE - 45 to 54 years',\n",
- " 'Percent Margin of Error; RACE - Race alone or in combination with one or more other races - Total population - American Indian and Alaska Native',\n",
- " 'Estimate; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Two or more races - Two races excluding Some other race, and Three or more races',\n",
- " 'Estimate; RACE - One race - Black or African American',\n",
- " 'Percent Margin of Error; RACE - Total population',\n",
- " 'Percent Margin of Error; RACE - One race - American Indian and Alaska Native - Chippewa tribal grouping',\n",
- " 'Margin of Error; SEX AND AGE - 20 to 24 years',\n",
- " 'Percent; RACE - One race - Black or African American',\n",
- " 'Margin of Error; RACE - Race alone or in combination with one or more other races - Total population - American Indian and Alaska Native',\n",
- " 'Margin of Error; SEX AND AGE - 65 years and over',\n",
- " 'Margin of Error; RACE - One race - American Indian and Alaska Native - Cherokee tribal grouping',\n",
- " 'Percent; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - American Indian and Alaska Native alone',\n",
- " 'Margin of Error; RACE - One race - Some other race',\n",
- " 'Estimate; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Two or more races',\n",
- " 'Margin of Error; RACE - Two or more races - White and American Indian and Alaska Native',\n",
- " 'Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Two or more races - Two races excluding Some other race, and Three or more races',\n",
- " 'Percent Margin of Error; RACE - Total population - One race',\n",
- " 'Estimate; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Native Hawaiian and Other Pacific Islander alone',\n",
- " 'Margin of Error; SEX AND AGE - 55 to 59 years',\n",
- " 'Percent; RACE - One race - Asian - Chinese',\n",
- " 'Percent Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - White alone',\n",
- " 'Margin of Error; SEX AND AGE - Total population - Female',\n",
- " 'Margin of Error; RACE - One race - American Indian and Alaska Native - Chippewa tribal grouping',\n",
- " 'Margin of Error; RACE - Two or more races - White and Asian',\n",
- " 'Estimate; SEX AND AGE - 18 years and over - Male',\n",
- " 'Percent Margin of Error; RACE - Two or more races - White and American Indian and Alaska Native',\n",
- " 'Margin of Error; SEX AND AGE - 15 to 19 years',\n",
- " 'Estimate; RACE - One race - Asian - Korean',\n",
- " 'Estimate; RACE - Race alone or in combination with one or more other races - Total population - Black or African American',\n",
- " 'Percent; RACE - One race - Native Hawaiian and Other Pacific Islander - Guamanian or Chamorro',\n",
- " 'Percent Margin of Error; RACE - Race alone or in combination with one or more other races - Total population',\n",
- " 'Margin of Error; SEX AND AGE - 45 to 54 years',\n",
- " 'Percent Margin of Error; SEX AND AGE - 45 to 54 years',\n",
- " 'Estimate; SEX AND AGE - 55 to 59 years',\n",
- " 'Percent; RACE - Total population - One race',\n",
- " 'Percent Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Two or more races - Two races including Some other race',\n",
- " 'Percent; RACE - One race - Native Hawaiian and Other Pacific Islander - Native Hawaiian',\n",
- " 'Percent; RACE - One race - American Indian and Alaska Native - Navajo tribal grouping',\n",
- " 'Estimate; RACE - One race - American Indian and Alaska Native - Cherokee tribal grouping',\n",
- " 'Margin of Error; SEX AND AGE - Total population',\n",
- " 'Margin of Error; HISPANIC OR LATINO AND RACE - Total population',\n",
- " 'Percent Margin of Error; SEX AND AGE - 10 to 14 years',\n",
- " 'Percent Margin of Error; RACE - One race - Asian - Vietnamese',\n",
- " 'Percent; RACE - One race - American Indian and Alaska Native - Sioux tribal grouping',\n",
- " 'Percent Margin of Error; HISPANIC OR LATINO AND RACE - Total housing units',\n",
- " 'Percent Margin of Error; RACE - One race - Native Hawaiian and Other Pacific Islander - Guamanian or Chamorro',\n",
- " 'Percent Margin of Error; SEX AND AGE - 15 to 19 years',\n",
- " 'Margin of Error; RACE - Total population',\n",
- " 'Estimate; RACE - Two or more races - Black or African American and American Indian and Alaska Native',\n",
- " 'Percent; RACE - Two or more races - White and Asian',\n",
- " 'Percent Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - American Indian and Alaska Native alone',\n",
- " 'Percent; RACE - One race - Asian - Asian Indian',\n",
- " 'Percent Margin of Error; SEX AND AGE - 18 years and over',\n",
- " 'Margin of Error; RACE - One race - Asian - Chinese',\n",
- " 'Estimate; SEX AND AGE - 85 years and over',\n",
- " 'Percent Margin of Error; RACE - One race - Native Hawaiian and Other Pacific Islander - Other Pacific Islander',\n",
- " 'Estimate; RACE - Race alone or in combination with one or more other races - Total population - White',\n",
- " 'Estimate; SEX AND AGE - 18 years and over - Female',\n",
- " 'Estimate; SEX AND AGE - 65 years and over - Male',\n",
- " 'Margin of Error; SEX AND AGE - 5 to 9 years',\n",
- " 'Estimate; SEX AND AGE - 75 to 84 years',\n",
- " 'Percent Margin of Error; SEX AND AGE - 55 to 59 years',\n",
- " 'Margin of Error; RACE - One race - American Indian and Alaska Native - Navajo tribal grouping',\n",
- " 'Estimate; RACE - One race - Asian - Other Asian',\n",
- " 'Margin of Error; RACE - One race - Native Hawaiian and Other Pacific Islander - Other Pacific Islander',\n",
- " 'Percent Margin of Error; SEX AND AGE - 65 years and over - Female',\n",
- " 'Percent; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Some other race alone',\n",
- " 'Estimate; SEX AND AGE - 20 to 24 years',\n",
- " 'Estimate; RACE - Total population - Two or more races',\n",
- " 'Percent; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Two or more races',\n",
- " 'Percent Margin of Error; RACE - One race - Native Hawaiian and Other Pacific Islander',\n",
- " 'Margin of Error; RACE - One race',\n",
- " 'Percent; RACE - Race alone or in combination with one or more other races - Total population - American Indian and Alaska Native',\n",
- " 'Margin of Error; SEX AND AGE - 25 to 34 years',\n",
- " 'Margin of Error; RACE - One race - Native Hawaiian and Other Pacific Islander - Guamanian or Chamorro',\n",
- " 'Percent; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Asian alone',\n",
- " 'Percent Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Native Hawaiian and Other Pacific Islander alone',\n",
- " 'Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Hispanic or Latino (of any race)',\n",
- " 'Percent Margin of Error; RACE - One race - Asian - Korean',\n",
- " 'Estimate; RACE - One race - Native Hawaiian and Other Pacific Islander - Native Hawaiian',\n",
- " 'Percent; SEX AND AGE - 62 years and over',\n",
- " 'Percent; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Black or African American alone',\n",
- " 'Margin of Error; RACE - One race - American Indian and Alaska Native',\n",
- " 'Percent; RACE - Race alone or in combination with one or more other races - Total population - Native Hawaiian and Other Pacific Islander',\n",
- " 'Percent; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino',\n",
- " 'Estimate; RACE - One race - Some other race',\n",
- " 'Estimate; RACE - Race alone or in combination with one or more other races - Total population - Asian',\n",
- " 'Percent; HISPANIC OR LATINO AND RACE - Total population - Hispanic or Latino (of any race)',\n",
- " 'Estimate; SEX AND AGE - 15 to 19 years',\n",
- " 'Percent Margin of Error; RACE - Two or more races - Black or African American and American Indian and Alaska Native',\n",
- " 'Percent; RACE - Race alone or in combination with one or more other races - Total population - Black or African American',\n",
- " 'Margin of Error; HISPANIC OR LATINO AND RACE - Total housing units',\n",
- " 'Percent Margin of Error; SEX AND AGE - 18 years and over - Female',\n",
- " 'Percent Margin of Error; SEX AND AGE - 18 years and over',\n",
- " 'Percent Margin of Error; SEX AND AGE - 65 years and over',\n",
- " 'Percent; SEX AND AGE - 45 to 54 years',\n",
- " 'Percent; SEX AND AGE - Total population - Male',\n",
- " 'Percent; RACE - Race alone or in combination with one or more other races - Total population - Some other race',\n",
- " 'Percent; SEX AND AGE - 65 to 74 years',\n",
- " 'Estimate; RACE - One race',\n",
- " 'Estimate; RACE - One race - Asian - Vietnamese',\n",
- " 'Percent; SEX AND AGE - 55 to 59 years',\n",
- " 'Percent; RACE - Two or more races - White and American Indian and Alaska Native',\n",
- " 'Percent Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Hispanic or Latino (of any race) - Mexican',\n",
- " 'Percent; SEX AND AGE - 21 years and over',\n",
- " 'Percent; RACE - One race - Asian - Korean',\n",
- " 'Percent; SEX AND AGE - 65 years and over - Female',\n",
- " 'Percent; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Native Hawaiian and Other Pacific Islander alone',\n",
- " 'Margin of Error; SEX AND AGE - 18 years and over',\n",
- " 'Percent; RACE - Two or more races - White and Black or African American',\n",
- " 'Percent; SEX AND AGE - 18 years and over',\n",
- " 'Percent; RACE - One race - Native Hawaiian and Other Pacific Islander - Samoan',\n",
- " 'Percent; SEX AND AGE - Median age (years)',\n",
- " 'Estimate; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - Asian alone',\n",
- " 'Percent; SEX AND AGE - 18 years and over - Male',\n",
- " 'Estimate; SEX AND AGE - Total population - Male',\n",
- " 'Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Not Hispanic or Latino - White alone',\n",
- " 'Estimate; RACE - One race - American Indian and Alaska Native - Chippewa tribal grouping',\n",
- " 'Percent; SEX AND AGE - Under 5 years',\n",
- " 'Percent Margin of Error; HISPANIC OR LATINO AND RACE - Total population - Hispanic or Latino (of any race)',\n",
- " 'Estimate; SEX AND AGE - 18 years and over',\n",
- " 'Estimate; HISPANIC OR LATINO AND RACE - Total housing units',\n",
- " 'Percent; SEX AND AGE - 85 years and over',\n",
- " 'Estimate; RACE - One race - Asian - Japanese']"
+ " geo_display_label hc01_vc216 hc02_vc216 \\\n",
+ "1 Census Tract 101, San Francisco County, Califo... (X) (X) \n",
+ "2 Census Tract 102, San Francisco County, Califo... (X) (X) \n",
+ "3 Census Tract 103, San Francisco County, Califo... (X) (X) \n",
+ "4 Census Tract 104, San Francisco County, Califo... (X) (X) \n",
+ "5 Census Tract 105, San Francisco County, Califo... (X) (X) \n",
+ "\n",
+ " hc03_vc216 hc04_vc216 hc01_vc217 hc02_vc217 hc03_vc217 hc04_vc217 \\\n",
+ "1 (X) (X) (X) (X) (X) (X) \n",
+ "2 (X) (X) (X) (X) (X) (X) \n",
+ "3 (X) (X) (X) (X) (X) (X) \n",
+ "4 (X) (X) (X) (X) (X) (X) \n",
+ "5 (X) (X) (X) (X) (X) (X) \n",
+ "\n",
+ " hc01_vc218 hc02_vc218 hc03_vc218 hc04_vc218 \n",
+ "1 (X) (X) (X) (X) \n",
+ "2 (X) (X) (X) (X) \n",
+ "3 (X) (X) (X) (X) \n",
+ "4 (X) (X) (X) (X) \n",
+ "5 (X) (X) (X) (X) "
]
},
- "execution_count": 108,
+ "execution_count": 310,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
- "# Find columns that have name\n",
- "phrase = 'children'\n",
- "[value for value in data_dictionary.values()]# if value.find(phrase) > 0]"
+ "# Select columns\n",
+ "selected_cols = df_meta[df_meta.description.str.contains(phrase)].data_column_name.values\n",
+ "# Display data for those columns\n",
+ "df_data[['geo_display_label']+selected_cols.tolist()].head(n=5)"
]
},
{
"cell_type": "code",
- "execution_count": 101,
+ "execution_count": 259,
"metadata": {
- "collapsed": false
+ "collapsed": true
},
"outputs": [],
"source": [
- "value = 'Estimate; HOUSEHOLDS BY TYPE - Total households'"
+ "# Aggregate columns"
]
},
{
"cell_type": "code",
- "execution_count": 110,
+ "execution_count": 261,
"metadata": {
- "collapsed": false
+ "collapsed": true
},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "0 Id\n",
- "1 Id2\n",
- "2 Geography\n",
- "3 Estimate; SEX AND AGE - Total population\n",
- "4 Margin of Error; SEX AND AGE - Total population\n",
- "5 Percent; SEX AND AGE - Total population\n",
- "6 Percent Margin of Error; SEX AND AGE - Total p...\n",
- "7 Estimate; SEX AND AGE - Total population - Male\n",
- "8 Margin of Error; SEX AND AGE - Total populatio...\n",
- "9 Percent; SEX AND AGE - Total population - Male\n",
- "10 Percent Margin of Error; SEX AND AGE - Total p...\n",
- "11 Estimate; SEX AND AGE - Total population - Female\n",
- "12 Margin of Error; SEX AND AGE - Total populatio...\n",
- "13 Percent; SEX AND AGE - Total population - Female\n",
- "14 Percent Margin of Error; SEX AND AGE - Total p...\n",
- "15 Estimate; SEX AND AGE - Under 5 years\n",
- "16 Margin of Error; SEX AND AGE - Under 5 years\n",
- "17 Percent; SEX AND AGE - Under 5 years\n",
- "18 Percent Margin of Error; SEX AND AGE - Under 5...\n",
- "19 Estimate; SEX AND AGE - 5 to 9 years\n",
- "20 Margin of Error; SEX AND AGE - 5 to 9 years\n",
- "21 Percent; SEX AND AGE - 5 to 9 years\n",
- "22 Percent Margin of Error; SEX AND AGE - 5 to 9 ...\n",
- "23 Estimate; SEX AND AGE - 10 to 14 years\n",
- "24 Margin of Error; SEX AND AGE - 10 to 14 years\n",
- "25 Percent; SEX AND AGE - 10 to 14 years\n",
- "26 Percent Margin of Error; SEX AND AGE - 10 to 1...\n",
- "27 Estimate; SEX AND AGE - 15 to 19 years\n",
- "28 Margin of Error; SEX AND AGE - 15 to 19 years\n",
- "29 Percent; SEX AND AGE - 15 to 19 years\n",
- " ... \n",
- "297 Percent; HISPANIC OR LATINO AND RACE - Total p...\n",
- "298 Percent Margin of Error; HISPANIC OR LATINO AN...\n",
- "299 Estimate; HISPANIC OR LATINO AND RACE - Total ...\n",
- "300 Margin of Error; HISPANIC OR LATINO AND RACE -...\n",
- "301 Percent; HISPANIC OR LATINO AND RACE - Total p...\n",
- "302 Percent Margin of Error; HISPANIC OR LATINO AN...\n",
- "303 Estimate; HISPANIC OR LATINO AND RACE - Total ...\n",
- "304 Margin of Error; HISPANIC OR LATINO AND RACE -...\n",
- "305 Percent; HISPANIC OR LATINO AND RACE - Total p...\n",
- "306 Percent Margin of Error; HISPANIC OR LATINO AN...\n",
- "307 Estimate; HISPANIC OR LATINO AND RACE - Total ...\n",
- "308 Margin of Error; HISPANIC OR LATINO AND RACE -...\n",
- "309 Percent; HISPANIC OR LATINO AND RACE - Total p...\n",
- "310 Percent Margin of Error; HISPANIC OR LATINO AN...\n",
- "311 Estimate; HISPANIC OR LATINO AND RACE - Total ...\n",
- "312 Margin of Error; HISPANIC OR LATINO AND RACE -...\n",
- "313 Percent; HISPANIC OR LATINO AND RACE - Total p...\n",
- "314 Percent Margin of Error; HISPANIC OR LATINO AN...\n",
- "315 Estimate; HISPANIC OR LATINO AND RACE - Total ...\n",
- "316 Margin of Error; HISPANIC OR LATINO AND RACE -...\n",
- "317 Percent; HISPANIC OR LATINO AND RACE - Total p...\n",
- "318 Percent Margin of Error; HISPANIC OR LATINO AN...\n",
- "319 Estimate; HISPANIC OR LATINO AND RACE - Total ...\n",
- "320 Margin of Error; HISPANIC OR LATINO AND RACE -...\n",
- "321 Percent; HISPANIC OR LATINO AND RACE - Total p...\n",
- "322 Percent Margin of Error; HISPANIC OR LATINO AN...\n",
- "323 Estimate; HISPANIC OR LATINO AND RACE - Total ...\n",
- "324 Margin of Error; HISPANIC OR LATINO AND RACE -...\n",
- "325 Percent; HISPANIC OR LATINO AND RACE - Total h...\n",
- "326 Percent Margin of Error; HISPANIC OR LATINO AN...\n",
- "Name: description, dtype: object"
- ]
- },
- "execution_count": 110,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
+ "outputs": [],
"source": [
- "df_meta.description."
+ "# Pivot "
]
},
{
@@ -1486,6 +808,28 @@
},
"outputs": [],
"source": []
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 262,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": [
+ "# Export as .csv"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": [
+ "# Upload to Drive"
+ ]
}
],
"metadata": {
diff --git a/sfhip-app/README.md b/sfhip-app/README.md
new file mode 100644
index 0000000..adacaac
--- /dev/null
+++ b/sfhip-app/README.md
@@ -0,0 +1,5 @@
+sfhip-app
+======
+
+Web application for SFHIP.
+Available at https://jrnew.shinyapps.io/sfhip-app.
diff --git a/sfhip-app/df_alcohol.rda b/sfhip-app/df_alcohol.rda
new file mode 100644
index 0000000..f9287f7
Binary files /dev/null and b/sfhip-app/df_alcohol.rda differ
diff --git a/sfhip-app/df_censustracts.rda b/sfhip-app/df_censustracts.rda
new file mode 100644
index 0000000..70671c5
Binary files /dev/null and b/sfhip-app/df_censustracts.rda differ
diff --git a/sfhip-app/df_censustracts_proc.rda b/sfhip-app/df_censustracts_proc.rda
new file mode 100644
index 0000000..53d48b5
Binary files /dev/null and b/sfhip-app/df_censustracts_proc.rda differ
diff --git a/sfhip-app/df_crime.rda b/sfhip-app/df_crime.rda
new file mode 100644
index 0000000..a80e443
Binary files /dev/null and b/sfhip-app/df_crime.rda differ
diff --git a/sfhip-app/global.R b/sfhip-app/global.R
new file mode 100644
index 0000000..88efa06
--- /dev/null
+++ b/sfhip-app/global.R
@@ -0,0 +1,137 @@
+library(shiny)
+library(shinydashboard)
+library(dplyr)
+library(ggplot2)
+library(scales) # to access breaks/formatting function for dates
+library(grid) # required for arrow
+library(ggmap)
+
+df_alcohol_file <- "processed_data/alcohol_licenses_locations.csv"
+df_alcohol <- read.csv(df_alcohol_file, stringsAsFactors = FALSE)
+df_crime_file <- "processed_data/Raw_Crime_Data_with_Projected_coords_andTract_REDUCED.csv"
+df_crime <- read.csv(df_crime_file, stringsAsFactors = FALSE)
+df_crime_centroids_file <- "processed_data/crime_centroids.csv"
+df_crime_centroids <- read.csv(df_crime_centroids_file,
+ stringsAsFactors = FALSE)
+df_allbycensustract_file <- "processed_data/crime_census_alcohol.csv"
+df_allbycensustract <- read.csv(df_allbycensustract_file, stringsAsFactors = FALSE)
+#----------------------------------------------------------------------
+get_limits <- function(x, factor = 1.05) {
+ # limits <- quantile(x, probs = c(0.025, 0.975))
+ limits <- range(x)
+ x <- x[x >= limits[1] & x <= limits[2]]
+ minx <- min(x, na.rm = TRUE)
+ maxx <- max(x, na.rm = TRUE)
+ meanx <- mean(x, na.rm = TRUE)
+ return(c(meanx - (meanx - minx) * factor,
+ meanx + (maxx - meanx) * factor))
+}
+#----------------------------------------------------------------------
+# Alcohol establishments
+if (!file.exists("df_alcohol.rda")) {
+ df_alcohol <- df_alcohol %>%
+ mutate(Premise_Type = ifelse(License_Ty %in% c(1:29, 79, 81, 82, 85, 86), "Off-sale", "On-sale")) %>%
+ mutate(License_Ty = as.factor(License_Ty),
+ Premise_Type = as.factor(Premise_Type)) %>%
+ mutate(Orig_Iss_Date = as.POSIXct(Orig_Iss_D, format = "%Y/%m/%d"),
+ Orig_Iss_Year = as.numeric(sapply(Orig_Iss_D, function(x) strsplit(x, "/")[[1]][1])),
+ Orig_Iss_Month = as.numeric(sapply(Orig_Iss_D, function(x) strsplit(x, "/")[[1]][2])),
+ Orig_Iss_DateYM = as.POSIXct(paste(Orig_Iss_Year, Orig_Iss_Month, "01", sep = "-"),
+ format = "%Y-%m-%d")) %>%
+ mutate(Zip_Code = sapply(zip, function(x) strsplit(x, "-")[[1]][1]))
+ save(df_alcohol, file = "df_alcohol.rda")
+} else {
+ load("df_alcohol.rda")
+}
+
+onoff_categories <- as.character(unique(df_alcohol$Premise_Type))
+onoff_categories <- as.list(sort(onoff_categories, decreasing = TRUE))
+names(onoff_categories) <- c("On-premise alcohol sale", "Off-premise alcohol sale")
+
+# Crimes
+if (!file.exists("df_crime.rda")) {
+ df_crime <- df_crime %>%
+ mutate(Date_Orig = Date,
+ Date = as.POSIXct(sapply(Date, function(x) strsplit(x, " ")[[1]][1]), format = "%Y-%m-%d"),
+ Year = as.numeric(sapply(Date_Orig, function(x) strsplit(x, "-")[[1]][1])),
+ Month = as.numeric(sapply(Date_Orig, function(x) strsplit(x, "-")[[1]][2])),
+ DateYM = as.POSIXct(paste(Year, Month, "01", sep = "-"),
+ format = "%Y-%m-%d"),
+ Longitude = as.numeric(gsub("\\)", "", sapply(Location, function(x) strsplit(x, ", ")[[1]][2]))),
+ Latitude = as.numeric(gsub("\\(", "", sapply(Location, function(x) strsplit(x, ", ")[[1]][1]))))
+ df_crime <- df_crime[, colnames(df_crime) != "Date_Orig"]
+ save(df_crime, file = "df_crime.rda")
+} else {
+ load(file = "df_crime.rda")
+}
+
+# Crime centroids
+crime_categories <- unique(df_crime_centroids$Category)
+crime_categories <- crime_categories[!(crime_categories %in% "ALCOHOL STORES")]
+crime_categories_and_alcohol <- as.list(c("ALCOHOL STORES", crime_categories))
+crime_categories <- as.list(c("Please select", crime_categories))
+names(crime_categories) <- crime_categories ###
+names(crime_categories_and_alcohol) <- crime_categories_and_alcohol ###
+#----------------------------------------------------------------------
+# Census tracts shape files
+# ggmap: http://journal.r-project.org/archive/2013-1/kahle-wickham.pdf
+# http://www.kevjohnson.org/making-maps-in-r/
+# http://www.kevjohnson.org/making-maps-in-r-part-2/
+# Shape file downloaded for CA from https://www.census.gov/geo/maps-data/data/cbf/cbf_tracts.html
+if (!file.exists("df_censustracts.rda")) {
+ # # Fix weird error when boundaries of census tract intersect with boundaries of map
+ # library(raster)
+ # library(rgdal)
+ # library(rgeos)
+ # # 1. Install GDAL framework for MAC OS
+ # # 2. Install rgeos and rgdal from source, see http://tlocoh.r-forge.r-project.org/mac_rgeos_rgdal.html
+ # # a. First download source package of rgdal/rgeos
+ # # b. In terminal:
+ # # R CMD INSTALL ~/Copy/sfhip/libraries/rgdal_0.9-2.tar.gz --configure-args='--with-gdal-config=/Library/Frameworks/GDAL.framework/Programs/gdal-config
+ # # --with-proj-include=/Library/Frameworks/PROJ.framework/Headers
+ # # --with-proj-lib=/Library/Frameworks/PROJ.framework/unix/lib'
+ # # R CMD INSTALL ~/Copy/sfhip/libraries/rgeos_0.3-9.tar.gz --configure-args='--with-geos-config=/Library/Frameworks/GEOS.framework/unix/bin/geos-config'
+ box <- as(extent(as.numeric(attr(map, 'bb'))[c(2,4,1,3)] + c(.001,-.001,.001,-.001)), "SpatialPolygons")
+ tract <- readOGR(dsn = "processed_data/gz_2010_06_140_00_500k", layer = "gz_2010_06_140_00_500k")
+ proj4string(box) <- CRS(summary(tract)[[4]])
+ df_censustracts <- gIntersection(tract, box, byid = TRUE, id = as.character(tract$TRACT))
+ df_censustracts <- fortify(df_censustracts, id = "TRACT")
+ save(df_censustracts, file = "df_censustracts.rda")
+} else {
+ load("df_censustracts.rda")
+}
+# Alternative way of getting shape file...
+# library(maptools)
+# library(gpclib)
+# library(sp)
+# gpclibPermit()
+# if (!file.exists("df_censustracts.rda")) {
+# shapefile <- readShapeSpatial("processed_data/gz_2010_06_140_00_500k/gz_2010_06_140_00_500k.shp",
+# proj4string = CRS("+proj=longlat +datum=WGS84"),
+# IDvar = "GEO_ID")
+# # Convert to a data.frame for use with ggplot2/ggmap and plot
+# df_censustracts <- fortify(shapefile, id = "GEO_ID")
+# df_censustracts$id <- substring(df_censustracts$id,
+# nchar(df_censustracts$id[1]) - 5, nchar(df_censustracts$id[1]))
+# save(df_censustracts, file = "df_censustracts.rda")
+# } else {
+# load("df_censustracts.rda")
+# }
+#----------------------------------------------------------------------
+if (!file.exists("df_censustracts_proc.rda")) {
+ # Alcohol and crime rates by census tracts
+ df_allbycensustract <- df_allbycensustract %>%
+ mutate(Tract2010 = as.character(Tract2010)) %>%
+ mutate(Tract2010 = ifelse(nchar(Tract2010) == 5, paste0("0", Tract2010), Tract2010))
+ # intersect(df_allbycensustract$Tract2010, df_censustracts$id)
+ df_censustracts_proc <- df_censustracts %>%
+ left_join(df_allbycensustract, by = c("id" = "Tract2010")) %>%
+ filter(!is.na(Pop2010))
+ save("df_censustracts_proc", file = "df_censustracts_proc.rda")
+} else {
+ load("df_censustracts_proc.rda")
+}
+plotcategories <- names(df_censustracts_proc)
+plotcategories <- c("Please select",
+ plotcategories[!(plotcategories %in%
+ c("id", "long", "lat", "order", "hole", "piece", "group"))])
diff --git a/sfhip-app/server.R b/sfhip-app/server.R
new file mode 100644
index 0000000..4e09b54
--- /dev/null
+++ b/sfhip-app/server.R
@@ -0,0 +1,58 @@
+server <- function(input, output) {
+ output$map <- renderPlot({
+ p_theme <- theme(axis.line=element_blank(), axis.text.x=element_blank(),
+ axis.text.y=element_blank(), axis.ticks=element_blank(),
+ axis.title.x=element_blank(), axis.title.y=element_blank(),
+ plot.margin = unit(c(0,0,0,0), "cm"),
+ # legend.position="none",
+ panel.background=element_blank(),panel.border=element_blank(),panel.grid.major=element_blank(),
+ panel.grid.minor=element_blank(),plot.background=element_blank()
+ )
+ # Set up map
+ map <- get_map(location = c(lon = mean(df_alcohol$X),
+ lat = mean(df_alcohol$Y)),
+ maptype = "roadmap", source = "google", zoom = 12)
+ p <- ggmap(map,
+ base_layer = ggplot(data = df_censustracts_proc,
+ aes(x = long, y = lat))) +
+ scale_x_continuous(limits = c(-122.52, -122.36)) +
+ scale_y_continuous(limits = c(37.708, 37.835)) +
+ xlab("") + ylab("") + p_theme
+ # Plot chloropeth regions
+ if (input$select_plot_category != "Please select") {
+ p <- p + geom_polygon(aes_string(group = "group", fill = input$select_plot_category),
+ colour = "white", alpha = 0.4, size = 0.3) +
+ scale_fill_distiller(palette = "Blues", name = input$select_plot_category,
+ breaks = pretty_breaks(n = 5))
+ }
+ # Plot crime density
+ if (input$select_crime_categories != "Please select") {
+ select_df_crime <- df_crime$Category %in% input$select_crime_categories &
+ df_crime$Date >= as.POSIXct(input$dates_range[1], format = "%Y-%m-%d") &
+ df_crime$Date <= as.POSIXct(input$dates_range[2], format = "%Y-%m-%d")
+ p <- p +
+ stat_density2d(data = df_crime[select_df_crime, ],
+ aes(x = Longitude, y = Latitude, fill = ..level.., alpha = ..level..),
+ size = 2, bins = 10, geom = "polygon") +
+ scale_fill_distiller(palette = "YlOrRd", name = input$select_crime_categories,
+ breaks = pretty_breaks(n = 5))
+ }
+ # Plot alcohol establishments
+ select_df_alcohol <- df_alcohol$Premise_Type %in% input$select_onoff &
+ df_alcohol$Orig_Iss_Date >= as.POSIXct(input$dates_range[1], format = "%Y-%m-%d") &
+ df_alcohol$Orig_Iss_Date <= as.POSIXct(input$dates_range[2], format = "%Y-%m-%d")
+ p <- p + geom_point(data = df_alcohol[select_df_alcohol, ],
+ aes(x = X, y = Y, shape = Premise_Type), alpha = 0.5) +
+ scale_shape_discrete(name = "Establishment type")
+ # Plot centroids
+ if (!any(input$select_centroids == "Please select")) {
+ select_df_crime_centroids <- df_crime_centroids$Category %in% input$select_centroids
+ p <- p +
+ geom_point(data = df_crime_centroids[select_df_crime_centroids, ],
+ aes(x = Longitude, y = Latitude, colour = Category),
+ shape = 9, size = 4) + # or shape = 9
+ scale_colour_discrete(name = "Crime type (centroids)")
+ }
+ print(p)
+ })
+}
diff --git a/sfhip-app/shinyapps/jrnew/sfhip-app.dcf b/sfhip-app/shinyapps/jrnew/sfhip-app.dcf
new file mode 100644
index 0000000..12d0e9e
--- /dev/null
+++ b/sfhip-app/shinyapps/jrnew/sfhip-app.dcf
@@ -0,0 +1,4 @@
+name: sfhip-app
+account: jrnew
+bundleId: 155040
+url: http://jrnew.shinyapps.io/sfhip-app
diff --git a/sfhip-app/ui.R b/sfhip-app/ui.R
new file mode 100644
index 0000000..a551501
--- /dev/null
+++ b/sfhip-app/ui.R
@@ -0,0 +1,57 @@
+header <- dashboardHeader(title = "SFHIP")
+
+sidebar <- dashboardSidebar(
+ disable = TRUE)
+
+# sidebar <- dashboardSidebar(
+# sidebarMenu(
+# id = "tabs", # Setting id makes input$tabs give the tabName of currently-selected tab
+# # menuItem("Overview", tabName = "overview", icon = icon("th")),
+# menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard"))
+# )
+# )
+
+body <- dashboardBody(
+# tabItems(
+# # Overview tab
+# tabItem(tabName = "overview",
+# h3("Overview of data tool")
+# ),
+ # Dashboard tab
+# tabItem(tabName = "dashboard",
+ fluidRow(
+ box(width = 9,
+ plotOutput("map", height = 500, width = 650)),
+ box(title = "Plot options", width = 3,
+ status = "primary",
+ solidHeader = TRUE,
+ collapsible = TRUE,
+ # sliderInput("dates_range", "Dates:",
+ # min = 2010, max = 2013, value = c(2010, 2013), step = 1, sep = ""),
+ dateRangeInput("dates_range", "Date range",
+ start = "2010-01-01", end = "2013-12-31",
+ min = "2010-01-01", max = "2013-12-31"),
+ checkboxGroupInput("select_onoff",
+ label = "Establishment type",
+ choices = onoff_categories,
+ selected = c("On-sale", "Off-sale")),
+ selectInput("select_plot_category",
+ label = "License/crime rate",
+ choices = plotcategories),
+ selectInput("select_crime_categories",
+ label = "Crime type (density)",
+ choices = crime_categories),
+ # checkboxGroupInput("select_crime_categories",
+ # label = "Crime type (density)",
+ # choices = crime_categories),
+ checkboxGroupInput("select_centroids",
+ label = "Crime type (centroids)",
+ choices = crime_categories_and_alcohol,
+ selected = "Please select"))
+ )
+# )
+# )
+)
+
+
+dashboardPage(header, sidebar, body)
\ No newline at end of file