U.S. election and government metadata
Project description
us-elections 🇺🇸
A package for working with US elections metadata. Like python-us, but for elections!
Quickstart
$ pip install us-elections
Classes
ElectionYear
from elections import ElectionYear
# GET A SPECIFIC YEAR'S ELECTIONS AND DATA:
election_year = ElectionYear(2018)
# <ElectionYear: 2020 (Presidential election cycle)>
# GET ELECTIONS IN THIS YEAR:
election_year.elections
# [<GeneralElection: Alabama Nov. 06, 2018>, ... ]
election_year.elections.general
election_year.elections.primary
# GET GOVERNMENTS BY LEVEL:
election_year.federal
# <FederalGovernment: United States of America>
election_year.states
# [<StateGovernment: Alabama>, <StateGovernment: Alaska>, ... ]
eyr.states.alabama
eyr.states.new_jersey
# GET A BRANCH WITHIN A GOVERNMENT:
election_year.federal.legislative
# <Branch: United States Federal Government legislative Branch>
election_year.states.alaska.executive
# <Executive Branch: Alaska State Government>
# GET SEATS UP FOR ELECTION:
election_year.federal.legislative.seats
# [<HouseSeat: Alaska U.S. House seat, at-large district>, ... ]
election_year.states.alaska.executive.seats
# [<ExecutiveSeat: Alaska Governor>, ... ]
election_year.seats.federal.senate
election_year.seats.federal.house
# FILTER BY STATE:
election_year.elections_for_state('TX')
# [<GeneralElection: Texas Nov. 06, 2018>, ... ]
election_year.federal.legislative.seats_for_state('TX')
# [<HouseSeat: Texas U.S. House seat, 1st district>, ... ]
election_year.federal.legislative.seats_for_state('TX').senate
# [<SenateSeat: Texas U.S. Senate seat, class I>]
SenateSeat
from elections import ElectionYear
election_year = ElectionYear(2018)
seat = election_year.federal.legislative.seats.senate[0]
seat.state
# <State:Arizona>
seat.incumbent
# 'Flake, Jeff'
seat.incumbent_party
# <Party: Republican Party>
seat.senate_class
# 'I'
# etc.
HouseSeat
from elections import ElectionYear
election_year = ElectionYear(2018)
seat = election_year.federal.legislative.seats.house[0]
seat.state
# <State:Alaska>
seat.district
#
seat.district_name
# 'at-large district'
seat.incumbent
# 'Young, Don'
seat.incumbent_party
# <Party: Republican Party>
# etc.
GeneralElection
from elections import ElectionYear
election_year = ElectionYear(2018)
election = election_year.elections.general[0]
election.state
# <State:Alabama>
election.election_date
# datetime.datetime(2018, 11, 6, 0, 0)
election.registration_deadline
# datetime.datetime(2018, 10, 22, 0, 0)
# etc.
PrimaryElection
from elections import ElectionYear
election_year = ElectionYear(2018)
election = election_year.elections.primary[0]
election.state
# <State:Alabama>
election.election_date
# datetime.datetime(2018, 6, 5, 0, 0)
election.gop_election_type
# 'open'
election.runoff_election_date
# datetime.datetime(2018, 7, 17, 0, 0)
# etc.
Contributing data
- Add data to one of the CSVs in the
db/
directory. - Build the package data files:
$ python build.py
- Submit a pull request!
Influences
This project borrows most of its software design from python-us.
Its data models are also heavily inspired by the DNC election data project.
Testing
$ pipenv install -d
$ pipenv run pytest
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
us-elections-0.2.0.tar.gz
(9.6 kB
view details)
Built Distribution
us_elections-0.2.0-py3-none-any.whl
(148.5 kB
view details)
File details
Details for the file us-elections-0.2.0.tar.gz
.
File metadata
- Download URL: us-elections-0.2.0.tar.gz
- Upload date:
- Size: 9.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/2.7.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b08f4aaa98dfc6d49e1f91324acf10842ce001453be5bfc3686d81aa22b5fe33 |
|
MD5 | 7ab1a8ddab1b8910c27e5b9606bb5fd7 |
|
BLAKE2b-256 | 1493a19826888c6538f2502b79c0c79bb2ea58368ae2b3a572411a2d83e6400c |
File details
Details for the file us_elections-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: us_elections-0.2.0-py3-none-any.whl
- Upload date:
- Size: 148.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/2.7.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5ba57fb3b55d1feb7cacf878a532ea665ba9bdd612e2aa2a44e271f43d6d7b88 |
|
MD5 | 527e0aa4fe45acd9c9048e94f9f51323 |
|
BLAKE2b-256 | 191948ea2862fdb5226e419893406a16c258c50068cb2031fc9c33914a09456c |