Skip to main content

Partisan Dislocation

Build Status

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 run flit publish.

Metadata

Release files for partisan_dislocation 0.8.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for partisan_dislocation 0.8.0
File Size Uploaded Provenance Actions
partisan_dislocation-0.8.0.tar.gz 9.3 kB Without provenance Details for partisan_dislocation-0.8.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for partisan_dislocation 0.8.0
File Interpreter ABI Platform Actions
partisan_dislocation-0.8.0-py3-none-any.whl Python 3 none any Details for partisan_dislocation-0.8.0-py3-none-any.whl

Total release size: 17.4 kB

Release files / partisan_dislocation-0.8.0.tar.gz

Download URL partisan_dislocation-0.8.0.tar.gz
Size 9.3 kB
Tags Source
SHA-256 checksum
How to use checksums
506606b0e41ac54c580867a115362a4aba108eeb6f8eb0b7281d3af6b969a8d3
BLAKE2b-256 checksum
How to use checksums
3854af2fcdd61f5560c4f304e50cc77bb14fb2583148874486caa279863ee880
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.26.0

Release files / partisan_dislocation-0.8.0-py3-none-any.whl

Download URL partisan_dislocation-0.8.0-py3-none-any.whl
Size 8.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2bc0808af82abc160cfc180a0ef4771f3d65a58653a8736a8f7d3dd45ae847e9
BLAKE2b-256 checksum
How to use checksums
296637c118a1cd009038e04ed0fd17cff505c46885581fb75c54d4ac129f5daf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.26.0

Security for partisan_dislocation 0.8.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page