A package for converting US ZIP code to US Census Region and Division
Project description
us-zip-census
uszipcensus is a lightweight Python package that converts US ZIP codes into their corresponding Census Division and Region names.
GitHub Repo: https://github.com/kris-szczepaniak/us-zip-census
Features
- Works with both 5-digit or 5+4-digit format.
Division Mapping: Converts a valid ZIP code to its corresponding Census Division.Region Mapping: Maps a valid ZIP code to its Census Region.
Installation
Install uszipcensus via pip:
pip install uszipcensus
Usage
Import the package and call the functions directly:
import uszipcensus
division = uszipcensus.zip_to_division("12345")
region = uszipcensus.zip_to_region("12345")
print("Division:", division)
print("Region:", region)
API Overview
-
zip_to_division(zip_code: str) -> str
Validates the ZIP code and returns the name of the Census Division. Raises a ValueError if the ZIP code is invalid or if the division cannot be determined. -
zip_to_region(zip_code: str) -> str
Converts a ZIP code to its Census Region by first mapping it to a division. Raises a ValueError if the region cannot be determined.
Contributing
Contributions are welcome! Please open an issue or submit a pull request with your improvements.
Acknowledgements
This package uses a great package zipcodes.
Please find it here: https://pypi.org/project/zipcodes/
Project details
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 us_zip_census-0.1.2.tar.gz.
File metadata
- Download URL: us_zip_census-0.1.2.tar.gz
- Upload date:
- Size: 2.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.2 CPython/3.12.5 Darwin/24.2.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7d23b4520fd538cfb05157bc8717327090a664f92342f9cd4ee931af3046e4f
|
|
| MD5 |
16639dfcb1c861a46a426c67783c20f0
|
|
| BLAKE2b-256 |
beb12dfa73a339e895867c5c82b94b80961cc17773b877556b2afca4aad04fae
|
File details
Details for the file us_zip_census-0.1.2-py3-none-any.whl.
File metadata
- Download URL: us_zip_census-0.1.2-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.2 CPython/3.12.5 Darwin/24.2.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
07a703eb2bf1df5b6120e54e8877c6eded917e773243d3f8bcdf609491893645
|
|
| MD5 |
f2049fc959ae4fa893dbb805cb2b8447
|
|
| BLAKE2b-256 |
c63498057c9a1b39374ff6ad41add788f9fa1c9ef53f06318fc3bcf8cf57a6ac
|