Skip to content

Commit

Permalink
Retrieved and included income data from ACS; corrected unit count totals
Browse files Browse the repository at this point in the history
  • Loading branch information
james-tyner committed Feb 19, 2019
1 parent 231509c commit 788eab7
Show file tree
Hide file tree
Showing 70 changed files with 40,941 additions and 9 deletions.
Binary file added .DS_Store
Binary file not shown.
Binary file added 1031552_MasterZipCodes.pdf
Binary file not shown.
Binary file added 1031552_MasterZipCodes.xlsx
Binary file not shown.
4 changes: 0 additions & 4 deletions analyze-data.py

This file was deleted.

60 changes: 60 additions & 0 deletions check-extremes.py
@@ -0,0 +1,60 @@
import sqlite3

years = [
2013,
2014,
2015,
2016,
2017,
2018,
2019
]
# Future: add code to add the current year to the list if it's not already there

database = sqlite3.connect("permit_data.db")
cursor = database.cursor()

resultsFile = open("extremes.txt", "w")

for year in years:
resultsFile.write("----------------------------\n")
resultsFile.write("Year: " + str(year) + "\n\n")

# ZIP code with minimum
# command = """
# SELECT ZIP, MIN(%s)
# FROM statistics;
# """ % ("Units" + str(year))

command = """
SELECT ZIP, %s, MedIncome, Description
FROM statistics
WHERE %s = 0;
""" % ("Units" + str(year), "Units" + str(year))

cursor.execute(command)
resultsFile.write("ZIPs with zero units:\n")
for result in cursor:
resultsFile.write("ZIP " + str(result[0]) + ", " + str(result[3]) + " \n")
resultsFile.write("\t- Income: $" + str(result[2]) + "\n")
# resultsFile.write("\n")
# resultsFile.write("Min ZIP units: " + str(result[1]) + "\n\n")

# ZIP code with maximum
command = """
SELECT ZIP, MAX(%s), MedIncome, Description
FROM statistics;
""" % ("Units" + str(year))

cursor.execute(command)
resultsFile.write("\n")
for result in cursor:
resultsFile.write("Max: ZIP " + str(result[0]) + ", " + str(result[3]) + " \n")
resultsFile.write("\t- Income: $" + str(result[2]) + "\n")
resultsFile.write("Max ZIP units: " + str(result[1]) + "\n\n")

# checked data and found that maximums were never matched

database.commit()
database.close()
resultsFile.close()
File renamed without changes.
52 changes: 52 additions & 0 deletions create-statistics-table.py
@@ -0,0 +1,52 @@
import sqlite3
import csv

connection = sqlite3.connect("permit_data.db")
cursor = connection.cursor()

# completely eliminate the table so you can recreate it
cursor.execute("DROP TABLE statistics;")

command = """
CREATE TABLE statistics (
ZIP int PRIMARY KEY,
UnitsAll int,
Units2019 int,
Units2018 int,
Units2017 int,
Units2016 int,
Units2015 int,
Units2014 int,
Units2013 int,
MedIncome int,
Description varchar(50));"""

cursor.execute(command)

ZIPfile = open("zip-codes.txt", "r")

IncomeFile = open("median-income-2017.csv", "r")
IncomeReader = csv.DictReader(IncomeFile, delimiter=",")
IncomeDict = {}

DescFile = open("la-county-master-zips.csv", "r")
DescReader = csv.DictReader(DescFile, delimiter=",")
DescDict = {}

for row in IncomeReader:
IncomeDict[row["zip-code"]] = row["income"]

for row in DescReader:
DescDict[row["\xef\xbb\xbfzip-code"]] = row["area"] # not sure why all the extra characters but there they are

for ZIP in ZIPfile:
Income = IncomeDict[ZIP.strip()]
Desc = DescDict[ZIP.strip()]
cursor.execute("INSERT INTO statistics (ZIP, MedIncome, Description) VALUES (%s, %s, '%s');" % (ZIP, Income, Desc))

IncomeFile.close()
DescFile.close()
ZIPfile.close()

connection.commit()
connection.close()
178 changes: 178 additions & 0 deletions extremes.txt
@@ -0,0 +1,178 @@
----------------------------
Year: 2013

ZIPs with zero units:
ZIP 90042, Highland Park (City of LA)
- Income: $55596
ZIP 90036, Park La Brea (City of LA)
- Income: $74279
ZIP 91605, North Hollywood
- Income: $43004
ZIP 91325, Northridge (City of LA)
- Income: $65129
ZIP 90025, Sawtelle (City of LA)/West Los Angeles (City of LA)
- Income: $78713
ZIP 91345, Mission Hills (City of LA)
- Income: $74193
ZIP 91324, Northridge (City of LA)
- Income: $68477
ZIP 91307, West Hills (City of LA)
- Income: $111043
ZIP 91402, Panorama City (City of LA)
- Income: $41669
ZIP 91311, Chatsworth (City of LA)
- Income: $82738
ZIP 91606, North Hollywood
- Income: $44773
ZIP 90026, Echo Park/Silverlake (City of LA)
- Income: $54342
ZIP 90043, Hyde Park (City of LA)/View Park/Windsor Hills
- Income: $41812
ZIP 91304, Canoga Park (City of LA)
- Income: $64367
ZIP 90041, Eagle Rock (City of LA)
- Income: $73250
ZIP 91331, Arleta (City of LA)/Pacoima (City of LA)
- Income: $57353
ZIP 90004, Hancock Park (City of LA)
- Income: $46581
ZIP 91411, Van Nuys (City of LA)
- Income: $50332
ZIP 90744, Wilmington (City of LA)
- Income: $43284
ZIP 90032, El Sereno (City of LA)/Monterey Hills (City of LA)
- Income: $47370
ZIP 90020, Hancock Park (City of LA)
- Income: $42407
ZIP 90501, Torrance
- Income: $64995
ZIP 90031, Montecito Heights (City of LA)
- Income: $41126
ZIP 91364, Woodland Hills (City of LA)
- Income: $100323
ZIP 91303, Canoga Park (City of LA)
- Income: $51486
ZIP 90732, Rancho Palos Verdes
- Income: $89440
ZIP 90005, Koreatown (City of LA)
- Income: $32461
ZIP 90292, Marina del Rey
- Income: $103948
ZIP 90717, Lomita/Rancho Palos Verdes
- Income: $61077

Max: ZIP 90015, Downtown Los Angeles (City of LA)
- Income: $32979
Max ZIP units: 348

----------------------------
Year: 2014

ZIPs with zero units:
ZIP 91307, West Hills (City of LA)
- Income: $111043
ZIP 91306, Winnetka (City of LA)
- Income: $64772
ZIP 91343, North Hills (City of LA)
- Income: $61692
ZIP 90020, Hancock Park (City of LA)
- Income: $42407
ZIP 90717, Lomita/Rancho Palos Verdes
- Income: $61077

Max: ZIP 90013, Downtown Los Angeles (City of LA)
- Income: $22808
Max ZIP units: 159

----------------------------
Year: 2015

ZIPs with zero units:
ZIP 90020, Hancock Park (City of LA)
- Income: $42407
ZIP 91504, Burbank (Glenoaks)
- Income: $73501
ZIP 90008, Baldwin Hills/Crenshaw (City of LA)/Leimert Park (City of LA)
- Income: $36641
ZIP 91340, San Fernando
- Income: $54703

Max: ZIP 90015, Downtown Los Angeles (City of LA)
- Income: $32979
Max ZIP units: 1526

----------------------------
Year: 2016

ZIPs with zero units:
ZIP 91345, Mission Hills (City of LA)
- Income: $74193
ZIP 91307, West Hills (City of LA)
- Income: $111043
ZIP 90063, City Terrace
- Income: $44121
ZIP 91205, Glendale (Tropico)
- Income: $38730
ZIP 90247, Gardena
- Income: $46076
ZIP 91214, La Crescenta
- Income: $94322

Max: ZIP 90094, Playa Vista
- Income: $136250
Max ZIP units: 1844

----------------------------
Year: 2017

ZIPs with zero units:
ZIP 91504, Burbank (Glenoaks)
- Income: $73501
ZIP 90017, Downtown Los Angeles (City of LA)
- Income: $28638

Max: ZIP 90015, Downtown Los Angeles (City of LA)
- Income: $32979
Max ZIP units: 1821

----------------------------
Year: 2018

ZIPs with zero units:
ZIP 91504, Burbank (Glenoaks)
- Income: $73501
ZIP 91505, Burbank
- Income: $82630

Max: ZIP 91601, North Hollywood (City of LA)
- Income: $50832
Max ZIP units: 937

----------------------------
Year: 2019

ZIPs with zero units:
ZIP 91307, West Hills (City of LA)
- Income: $111043
ZIP 90020, Hancock Park (City of LA)
- Income: $42407
ZIP 91335, Reseda (City of LA)
- Income: $55580
ZIP 90031, Montecito Heights (City of LA)
- Income: $41126
ZIP 90067, Century City (City of LA)
- Income: $123889
ZIP 90732, Rancho Palos Verdes
- Income: $89440
ZIP 90710, Harbor City (City of LA)
- Income: $57968
ZIP 91504, Burbank (Glenoaks)
- Income: $73501
ZIP 90057, Westlake (City of LA)
- Income: $31337
ZIP 90013, Downtown Los Angeles (City of LA)
- Income: $22808

Max: ZIP 90036, Park La Brea (City of LA)
- Income: $74279
Max ZIP units: 287
35 changes: 35 additions & 0 deletions factfinder-data/ACS_17_5YR_B01003.txt
@@ -0,0 +1,35 @@
B01003
TOTAL POPULATION

Universe: Total population

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.


Supporting documentation on code lists, subject definitions, data accuracy, and statistical testing can be found on the American Community Survey website in the Technical Documentation section.

Sample size and data quality measures (including coverage rates, allocation rates, and response rates) can be found on the American Community Survey website in the Methodology section.


Source: U.S. Census Bureau, 2013-2017 American Community Survey 5-Year Estimates


Explanation of Symbols:An '**' entry in the margin of error column indicates that either no sample observations or too few sample observations were available to compute a standard error and thus the margin of error. A statistical test is not appropriate.
An '-' entry in the estimate column indicates that either no sample observations or too few sample observations were available to compute an estimate, or a ratio of medians cannot be calculated because one or both of the median estimates falls in the lowest interval or upper interval of an open-ended distribution.
An '-' following a median estimate means the median falls in the lowest interval of an open-ended distribution.
An '+' following a median estimate means the median falls in the upper interval of an open-ended distribution.
An '***' entry in the margin of error column indicates that the median falls in the lowest interval or upper interval of an open-ended distribution. A statistical test is not appropriate.
An '*****' entry in the margin of error column indicates that the estimate is controlled. A statistical test for sampling variability is not appropriate.
An 'N' entry in the estimate and margin of error columns indicates that data for this geographic area cannot be displayed because the number of sample cases is too small.
An '(X)' means that the estimate is not applicable or not available.


Data are based on a sample and are subject to sampling variability. The degree of uncertainty for an estimate arising from sampling variability is represented through the use of a margin of error. The value shown here is the 90 percent margin of error. The margin of error can be interpreted roughly as providing a 90 percent probability that the interval defined by the estimate minus the margin of error and the estimate plus the margin of error (the lower and upper confidence bounds) contains the true value. In addition to sampling variability, the ACS estimates are subject to nonsampling error (for a discussion of nonsampling variability, see Accuracy of the Data). The effect of nonsampling error is not represented in these tables.


While the 2013-2017 American Community Survey (ACS) data generally reflect the February 2013 Office of Management and Budget (OMB) definitions of metropolitan and micropolitan statistical areas; in certain instances the names, codes, and boundaries of the principal cities shown in ACS tables may differ from the OMB definitions due to differences in the effective dates of the geographic entities.


Estimates of urban and rural populations, housing units, and characteristics reflect boundaries of urban areas defined based on Census 2010 data. As a result, data for urban and rural areas from the ACS do not necessarily reflect the results of ongoing urbanization.


5 changes: 5 additions & 0 deletions factfinder-data/ACS_17_5YR_B01003_metadata.csv
@@ -0,0 +1,5 @@
GEO.id,Id
GEO.id2,Id2
GEO.display-label,Geography
HD01_VD01,Estimate; Total
HD02_VD01,Margin of Error; Total

0 comments on commit 788eab7

Please sign in to comment.