Skip to main content

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

us_zip_census-0.1.0.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

us_zip_census-0.1.0-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file us_zip_census-0.1.0.tar.gz.

File metadata

  • Download URL: us_zip_census-0.1.0.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

Hashes for us_zip_census-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e0f3f9965b026b5ae89c3aed70b874eb7fb012f0391724796994865c2c621bc8
MD5 6a909b035b2f5423e446dc0fa1c0abd7
BLAKE2b-256 4ee34f0a03c2d39c25e199f3736167cd798f3acbcdc0050fdcd8238b589caacd

See more details on using hashes here.

File details

Details for the file us_zip_census-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: us_zip_census-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.9 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

Hashes for us_zip_census-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0d462943fa3efd95ecb27962de9480054ae840311c9d44a4a99951a13afe97cd
MD5 41503b666dacbc2022c4035c0f3f409c
BLAKE2b-256 8df195202801e87249cc02a62890ce913f9a7d4a864dfce17be122d36d646632

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page