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.1.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.1-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: us_zip_census-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 68c465f40d066cd953b73aad762ecb1dc0755f38850ef1d9ff8bbdf85cfb4930
MD5 49267dd889f1a08bd7d9aeef1f04700e
BLAKE2b-256 a1c1d0f46fdbfa40f0f12f78656741f78eb8799c98bb45cf6f5ee5b03f68cf57

See more details on using hashes here.

File details

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

File metadata

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

Hashes for us_zip_census-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 73ce91b429f809d70906a8c534db22a607a1c65dae20b3fbb9863deb5e217383
MD5 169dffb46b1bb85931d42b0a00594fac
BLAKE2b-256 179d1e35937d282af2f843c29e25b51d21f1b585a3f934aada3685121ee6a3e7

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