Partisan Dislocation
Project description
Partisan Dislocation
This package implements the partisan dislocation measure from Partisan Dislocation: A Precinct-Level Measure ofRepresentation and Gerrymandering by Deford, Eubank, & Rodden.
It takes as input a GeoDataframe of polygons with columns containing vote counts for both political parties for each polygon. it includes three functions which, when used sequentially, will return a GeoDataframe of representative voter point along with associated dislocation scores for each point.
In addition, the repository for this package also include the shapefiles of US precincts and their vote totals from the 2008 presidential election used in Deford, Eubank, Rodden. these can be found in the folder "2008_presidential_precinct_data." It also includes CSV containing all of the underlying data behind Figure 10 from the Partisan Dislocation paper in the folder "figure_10_csv". Note that to download this data, you will have to first install git-lfs before cloning the repository.
The three functions provided by the package are:
random_points_in_polygon
: takes a polygon GeoDataframe with the number of votes cast democrats and republicans in each polygon and returns a GeoDataframe off of representative voter points.calculate_voter_knn
: takes a voter point GeoDataframe and returns a voter point GeoDataframe with voter knn scores.calculate_dislocation
: takes a voter point GeoDataframe with knn scores and a GeoDataframe with electoral district polygons and returns voter dislocation scores.
Tutorial
Demonstration of how the package can be used can be found in dislocation_tutorial.ipynb.
Installation
This package can be easily installed using pip
:
pip install partisan_dislocation
Dislocation Maps
This repository also includes partisan dislocation maps --- analogous to those in Deford, Eubank, Rodden --- for all states and legislative levels. Those can be found in the partisan_dislocation_maps
folder.
Development Notes
- To run test suite, set working directory to top level and run
python -m unittest partisan_dislocation/tests/test_partisan_dislocation.py
(after ensuring pip-installed version of package not in current environment). - To build package: install flit, and from root directory run
flit build
. - To install locally, build then run
flit install
. - To create new release, build, update version in
__init__.py
, then runflit publish
.
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
Built Distribution
Hashes for partisan_dislocation-0.8.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 506606b0e41ac54c580867a115362a4aba108eeb6f8eb0b7281d3af6b969a8d3 |
|
MD5 | 7fef3128987be70fbe9a08ec2eed863d |
|
BLAKE2b-256 | 3854af2fcdd61f5560c4f304e50cc77bb14fb2583148874486caa279863ee880 |
Hashes for partisan_dislocation-0.8.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2bc0808af82abc160cfc180a0ef4771f3d65a58653a8736a8f7d3dd45ae847e9 |
|
MD5 | 01ea5a4ea2e0ec1212b44cbbf7bf1ab3 |
|
BLAKE2b-256 | 296637c118a1cd009038e04ed0fd17cff505c46885581fb75c54d4ac129f5daf |