Code Monkey home page Code Monkey logo

latimes-statestyle's Introduction

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 

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

Build Status PyPI version Coverage Status

Features

  • Submit a state’s name, postal code or Associated Press abbreviation or FIPS code 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 obj.name
California
>>> print obj.postal
CA
>>> print obj.ap
Calif.
# Get by FIPS code
>>> obj = statestyle.get(6)
# Same attributes available
>>> print obj.name
California
>>> obj.stateface
"E"
# 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/__init__.py", line 27, in get
    raise ValueError("The state you requested does not exist")
ValueError: The state you requested does not exist

Contributing

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

latimes-statestyle's People

Contributors

palewire avatar ftobia avatar

Watchers

Chris Amico avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.