Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

Chicago meta information and other fun stuff

Project description

Information about Chicago and it’s geographies. Inspired by python-us.

Because sometimes you just need to loop through a list of Chicago neighborhoods.


Install using pip:

pip install chicago


Iterate over community areas

>>> from chicago import COMMUNITY_AREAS
>>> for ca in COMMUNITY_AREAS:
...     print(, ca.number)
('Rogers Park', '1')
('West Ridge', '2')
('Uptown', '3')
('Lincoln Square', '4')
('North Center', '5')
('Lake View', '6')
('Lincoln Park', '7')
('Near North Side', '8')
('Edison Park', '9')

Get a community area by number

>>> COMMUNITY_AREAS.get_by_number(22)
CommunityArea(name='Logan Square', number='22')

Iterate over neighborhoods

>>> from chicago import NEIGHBORHOODS
>>> for n in NEIGHBORHOODS:
...     print(n)
Albany Park
Archer Heights
Armour Square
Auburn Gresham
Avalon Park
Belmont Cragin

Iterate over census tracts

>>> from chicago import TRACTS
>>> for tract in TRACTS:
...     print(tract)

Get the census tract that contains a Chicago precinct

>>> from chicago import PRECINCTS
>>> precinct = PRECINCTS[0]
>>> from chicago import get_tract_from_precinct_id
>>> tract = get_tract_from_precinct_id(precinct.full_name)
>>> print(tract)

Get the census tract that contains a suburban Cook county precinct

>>> from chicago.cook_suburbs import COOK_SUBURBAN_PRECINCTS, get_suburban_cook_tract_from_precinct_number
>>> tract = get_suburban_cook_tract_from_precinct_number(precinct.objectid)
>>> print(tract)

Data Sources


Boundaries - Neighborhoods from the City of Chicago Data Portal

Building the data

This package uses Invoke to generate the data files that underly the Python API.

Cleaning up build files

invoke clean

Building the data files

This includes the precinct to census tract crosswalk CSVs.

invoke build

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for chicago, version 0.4.1
Filename, size File type Python version Upload date Hashes
Filename, size chicago-0.4.1.tar.gz (1.7 MB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page