Compare ZIP-area internet access and devices in Python
Join fictional service territories to genuine Census internet and device estimates, retaining uncertainty and unmatched ZIPs.
Compare household internet access across service areas
A business offering online appointments or forms has a list of postal ZIP codes. This reference adds household internet and device estimates that can inform its research into mobile-friendly forms, telephone support and offline options.
input.csv contains four fictional service territories. The identical records appear in the territories list in the Python code below. The territory labels and ZIP selections illustrate the join; the Census estimates are genuine.
Download zcta_internet.csv below and save it in your working directory. This is a smaller version of the paid summary file: complete profiles for ZCTAs 01001, 10001 and 27513, with all 47 fields unchanged. The optional input CSV is also embedded in the code.
The full $29 edition contains household profiles, 22 device/subscription categories per area, original counts, margins of error and coverage records in five data tables. The estimates describe 2020–2024.
A postal ZIP matched to the identically numbered Census ZCTA supplies approximate area context. ZIP+4 inputs use only five digits. A match does not validate an address or establish nine-digit precision.
Code example
This uses Python’s standard library and runs in a notebook, IPython or a script. It preserves every input row and prints three household shares with approximate 90% margins of error in percentage points.
Paths are relative to your working folder; use from pathlib import Path; print(Path.cwd()) to check it, or supply full paths.
"""Compare internet access and devices in fictional service territories. Paste into a notebook or run as a script."""
import csv
import re
from collections import Counter
# These fictional service territories also appear in example_input.csv. They
# illustrate a ZIP join, not real customers or evidence of demand.
territories = [
{'territory': 'A', 'postal_zip': '01001'},
{'territory': 'B', 'postal_zip': '27513-1234'},
{'territory': 'C', 'postal_zip': '10001'},
{'territory': 'D', 'postal_zip': '00000'},
]
def normalize_zip(value):
if value is None or isinstance(value, str) and not value.strip():
return '', '', 'missing_input'
if not isinstance(value, str): # Never guess lost leading zeros.
return '', '', 'invalid_format'
code = value.strip()
if re.fullmatch(r'[0-9]{5}', code):
return code, 'zip5_as_supplied', ''
if re.fullmatch(r'[0-9]{9}|[0-9]{5}-[0-9]{4}', code):
return code[:5], 'zip_plus4_to_zip5', ''
return '', '', 'invalid_format'
def load_profiles(filename):
profiles = {}
with open(filename, encoding='utf-8', newline='') as source:
for row in csv.DictReader(source):
code = row['zcta_code']
if not re.fullmatch(r'[0-9]{5}', code) or code in profiles:
raise ValueError('The reference must have one row per five-digit ZCTA.')
profiles[code] = row
return profiles
def enrich_territories(input_rows, profiles):
output = []
for order in input_rows:
code, method, problem = normalize_zip(order['postal_zip'])
area = profiles.get(code)
status = problem or ('matched_zcta_code' if area is not None else 'no_zcta_match')
row = {**order, 'zip5': code, 'normalization_method': method,
'match_resolution': 'zip5' if code else '', 'match_status': status,
'matched_zcta_code': code if area is not None else ''}
for field in [name + suffix for name in ('no_internet_access_pct', 'cellular_only_pct', 'smartphone_only_pct')
for suffix in ('', '_moe_90', '_status', '_moe_status')]:
row['area_' + field] = area[field] if area is not None else ''
output.append(row)
return output
profiles = load_profiles('zcta_internet.csv')
results = enrich_territories(territories, profiles)
assert len(results) == len(territories) # A many-to-one join must preserve input rows.
def display_share(row, metric):
stem = 'area_' + metric + '_pct'
if not row[stem]:
return row[stem + '_status']
margin = row[stem + '_moe_90']
uncertainty = f"± {float(margin):.1f} pp" if margin else row[stem + '_moe_status']
return f"{float(row[stem]):.1f}% {uncertainty}"
for row in results:
context = row['match_status']
if context == 'matched_zcta_code':
context = (f"ZCTA {row['matched_zcta_code']} | No internet access {display_share(row, 'no_internet_access')} | "
f"cellular-only internet {display_share(row, 'cellular_only')} | "
f"smartphone-only devices {display_share(row, 'smartphone_only')}")
print(f"{row['territory']} | ZIP {row['postal_zip']} | {context}")
print('Input match coverage:', dict(Counter(row['match_status'] for row in results)))
# All shares describe households. Cellular-only internet and smartphone-only
# devices are different, potentially overlapping measures. MOEs are approximate
# 90% margins in percentage points. ZIP+4 uses five digits. Area estimates do not
# identify an individual customer's connection, devices or service needs.
Analysis of the output
A | ZIP 01001 | ZCTA 01001 | No internet access 7.5% ± 4.2 pp | cellular-only internet 19.7% ± 3.7 pp | smartphone-only devices 12.3% ± 3.9 pp
B | ZIP 27513-1234 | ZCTA 27513 | No internet access 1.5% ± 0.7 pp | cellular-only internet 4.6% ± 1.5 pp | smartphone-only devices 1.5% ± 0.7 pp
C | ZIP 10001 | ZCTA 10001 | No internet access 2.4% ± 1.4 pp | cellular-only internet 10.0% ± 2.9 pp | smartphone-only devices 6.0% ± 2.3 pp
D | ZIP 00000 | no_zcta_match
Input match coverage: {'matched_zcta_code': 3, 'no_zcta_match': 1}
Territory B retains its ZIP+4 while matching ZCTA 27513 by the first five digits. About 1.5% of households reported no internet access at home, with an approximate margin of 0.7 percentage points. About 4.6% had a cellular data plan with no other internet subscription. The third figure, about 1.5%, describes households whose only computing device was a smartphone.
Cellular-only internet and smartphone-only devices answer different questions. A smartphone-only household could use home Wi-Fi; a cellular-only household could also have a laptop. These tables do not identify the overlap, so do not add the two percentages or treat them as the same households.
For the business, the useful result is a basis for investigating how accessible an online service would be across its territories. The figures can inform a review of mobile forms or alternative support channels. They do not establish what individual customers own, why households lack access, or which channel customers prefer.
Keep margins beside comparisons; this example does not test whether differences are statistically significant. Sampling uncertainty also does not measure postal-ZIP/ZCTA boundary differences. Territory D remains with no_zcta_match because 00000 is absent from the reference. Missing measures and zero denominators retain explicit statuses.
Using the full dataset
After purchase, replace the sample with the full zcta_internet.csv. Replace territories with records from your own CSV containing territory and postal_zip, keeping identifiers as text. The results list can be written to another CSV.
For another measure, select a category from access_categories.csv before joining. For example, B28002_006E identifies cellular-only subscriptions: pct uses all households, while pct_of_parent uses households with a cellular data plan. Both denominators and their uncertainty are supplied.
The full file also includes desktop/laptop access, cable/fiber/DSL subscriptions, access without a paid subscription, and no computing devices. Census’s “Broadband of any type” includes cellular and satellite connections. It is not a fixed-broadband or measured-speed statistic. Household subscriptions do not establish provider availability at an address.
Several device or subscription types may belong to one household. Even the last category in a hierarchy can overlap another category. Choose the measure your task needs rather than summing these categories. Repeated ZIPs in your input repeat area counts, so do not sum the joined household populations.
The ZIP-area demographic profile and language reference provide optional context for the same period and geography. Separate aggregate tables cannot identify which individual households have both characteristics. This example requires only the internet and devices reference.
Sources and versions
Source: U.S. Census Bureau, 2020–2024 ACS five-year tables B28001 and B28002, released January 29, 2026. Both describe households and exclude group quarters. The 2024 ACS geography reference uses 2020 ZCTA delineations and includes Puerto Rico.
Device definitions · Subscription definitions · ZCTA definitions · Source and preparation record.
Original count margins are retained. Derived shares use the documented Census subset approximation, with a flagged ratio fallback where required. Same-edition processing improvements and publisher error corrections are included. Future source editions may be sold separately.