(monadic) Precinct Matcher
Matching election data to shapefiles is hard. It is usually context-dependent and implemented on a project-by-project basis. It also sometimes involves some manual labor. This attempts to make life easier for everyone who has to deal with precinct matching.
Install
pip install pmatcher
Benchmarks (on real data)
VEST releases its precincts with VTD codes and county FIPS codes. To validate this approach, I ran the matcher on known, good data.
Results (in % accuracy):
Exact match 0.9444831591173054
Insensitive match 0.9444831591173054
Insensitive normalized match 0.9932636469221835
Aggressive insensitive normalized match 0.9983739837398374
Implemented Methods
-
matcher.default()Applies exact, insensitive, normalized, and weighted_manual in that order. All batteries included! -
matcher.exact()Matches exact strings. -
matcher.insensitive()Matches strings (case-insensitive). -
matcher.insensitive_normalized()Matches strings with special characters removed (e.g.(),#,-). -
matcher.weighted_manual()Uses a weighted levenshtein algorithm. First looks for token-distance, followed by token word distance for tiebreaking.
Saving and loading progress
-
matcher.save_progress("progress.json")Saves progress/mapping to a json file. -
matcher.load_progress("progress.json")Loads progress/mapping from a json file.
Example usage
from pmatcher import PrecinctMatcher
matcher = PrecinctMatcher(list_1, list_2)
mapping = matcher.default()
from pmatcher import PrecinctMatcher
matcher = PrecinctMatcher(list_1, list_2)
matcher.exact()
matcher.insensitive()
matcher.insensitive_normalized()
matcher.insensitive_normalized(aggressive=True)
mapping = matcher.weighted_manual()
Metadata
Release files for pmatcher 0.1.14
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pmatcher-0.1.14.tar.gz | 5.3 kB | Without provenance | Details for pmatcher-0.1.14.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pmatcher-0.1.14-py3-none-any.whl | Python 3 | none | any | Details for pmatcher-0.1.14-py3-none-any.whl |
Total release size: 10.8 kB
Release files / pmatcher-0.1.14.tar.gz
| Download URL | pmatcher-0.1.14.tar.gz |
|---|---|
| Size | 5.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b84fbcdb07727b84bb66c01f02641d2957a3272bee4e5e91ca8df27f87c40402
|
|
BLAKE2b-256 checksum How to use checksums |
fd995268b9e140b953ecf1c2bc2061f1f9877d61bc2734ae0d1927ad60bf70bb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.7 CPython/3.9.6 Linux/5.11.0-7620-generic
|
Release files / pmatcher-0.1.14-py3-none-any.whl
| Download URL | pmatcher-0.1.14-py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a48ae22b11ab78255b6e63288f1e4ad15989d1584beff0b47aeb88a0aff21a9b
|
|
BLAKE2b-256 checksum How to use checksums |
e5502da9b7d9a63fcfccea96713572e21beb59daecf4509c46ed80218959ec11
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.7 CPython/3.9.6 Linux/5.11.0-7620-generic
|
Security for pmatcher 0.1.14
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.