Skip to main content

Standardizes data about U.S. states

Project description

<pre><code>8""""8 8""""8
8 eeeee eeeee eeeee eeee 8 eeeee e e e eeee
8eeeee 8 8 8 8 8 8eeeee 8 8 8 8 8
88 8e 8eee8 8e 8eee 88 8e 8eeee8 8e 8eee
e 88 88 88 8 88 88 e 88 88 88 88 88
8eee88 88 88 8 88 88ee 8eee88 88 88 88eee 88ee </code></pre>

A Python library that standardizes the names of U.S. states

[![Build Status](](
[![PyPI version](](
[![Coverage Status](](

* Issues: [](
* Packaging: [](
* Testing: [](
* Coverage: [](


- Submit a state’s name, postal code or Associated Press abbreviation or [FIPS
and receive a clean object with all other formats as attributes.
- State objects also provide the “stateface” code for [ProPublica’s
web font of state shapes](

Getting started

Getting started is as easy as…

$ pip install latimes-statestyle

Then start feeding it your data:

>>> import statestyle
# Get by postal code
>>> obj = statestyle.get('CA')
# Fiddle with the clean attributes
>>> print
>>> print obj.postal
>>> print obj.ap
# Get by FIPS code
>>> obj = statestyle.get(6)
# Same attributes available
>>> print
>>> obj.stateface
# Here's what happens when you submit something that doesn have a match
>>> statestyle.get("foo")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "statestyle/", line 27, in get
raise ValueError("The state you requested does not exist")
ValueError: The state you requested does not exist


If you would like to add another feature or change existing data, edit
`statestyle/data.csv` and then run `python`, which will remake
the data file imported by the library.

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

latimes-statestyle-0.1.4.tar.gz (8.5 kB view hashes)

Uploaded Source

Supported by

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