A small package designed to help convert USPS ZIP Codes to OMB CBSA Codes
Project description
USPS ZIP Code to OMB Core-Based Satistical Area (CBSA)
Background:
For those unfamiliar, the US Office of Management and Budget (OMB) defines Core Based Statistical Areas (CBSAs) for use by a multitude of other agencies, including the US Dept of Housing and Urban Development.
Meanwhile, most developers and users are not intimately acquainted with the CBSA codes, but may well be accustomed to USPS ZIP Codes. The OMB publishes "crosswalk files" periodically to help map ZIP codes to CBSAs, and this package serves as an easy means to utilize those without needing to call an API constantly.
This package just has one function, "convert", which takes in a 5-digit USPS ZIP Code and returns all of the info for matching rows in the OMB ZIP-CBSA Crosswalk File, namely CBSA code, USPS ZIP Pref City, USPS ZIP Pref State, and four different ratios of percentage of addresses in a ZIP code mapped to the given CBSA based on designation as residential, business, other, and total addresses.
The return value from this function is a list of dictionaries, each dictionary corresponding to a CBSA associated to the given ZIP code. If an invalid ZIP code is provided, or the ZIP doesn't map to any CBSA, the function instead returns "FALSE".
For more info on OMB CBSAs, and on how to use the output data, please visit the US HUD portal site: https://www.huduser.gov/portal/datasets/usps_crosswalk.html
Usage:
from zipToCBSA import convert
results = convert('54499')
for result in results:
print(result)
results
{'zip': '54499', 'geoid': 43020, 'res_ratio': 0.817047817047817, 'bus_ratio': 0.9032258064516128, 'oth_ratio': 0.9428571428571428, 'tot_ratio': 0.8233766233766234, 'city': 'WITTENBERG', 'state': 'WI'}
{'zip': '54499', 'geoid': 48140, 'res_ratio': 0.167013167013167, 'bus_ratio': 0.0967741935483871, 'oth_ratio': 0.0571428571428571, 'tot_ratio': 0.1616883116883117, 'city': 'WITTENBERG', 'state': 'WI'}
{'zip': '54499', 'geoid': 44620, 'res_ratio': 0.0138600138600138, 'bus_ratio': 0.0, 'oth_ratio': 0.0, 'tot_ratio': 0.0129870129870129, 'city': 'WITTENBERG', 'state': 'WI'}
{'zip': '54499', 'geoid': 99999, 'res_ratio': 0.002079002079002, 'bus_ratio': 0.0, 'oth_ratio': 0.0, 'tot_ratio': 0.0019480519480519, 'city': 'WITTENBERG', 'state': 'WI'}
This code was inspired by the now-defunct zipcode2cbsa at https://github.com/macoj/zipcode2cbsa.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ziptocbsa-1.0.1.tar.gz.
File metadata
- Download URL: ziptocbsa-1.0.1.tar.gz
- Upload date:
- Size: 1.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f495468a4ee5efeb02571cf365d49948e20ed719afe1589f2fab83c5a96776af
|
|
| MD5 |
c371b7b07956904ef2716fba8fb83a0a
|
|
| BLAKE2b-256 |
809361f59b53b828899e67ffbc45e74c47a049f4ae3401ad06e9e3f303c0cf7b
|
File details
Details for the file ziptocbsa-1.0.1-py3-none-any.whl.
File metadata
- Download URL: ziptocbsa-1.0.1-py3-none-any.whl
- Upload date:
- Size: 742.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1bab821d5bcb2956de0783e4f383a52981a226c9cf90861b4ca35a852a2c0b52
|
|
| MD5 |
8535a1baa64e3b115bacffa09cf9ae83
|
|
| BLAKE2b-256 |
84ec21a48edf3a58bbfba7bee2a0bd88e585d7113c752e66d0b7ad315fbbc8cf
|