Uses data on redistricting to apply redistricting to older datasets to represent the districts in their current state.
Supports merging and splitting of districts:
- Merged districts are summed up under new identifier
- Split districts are distributed by population-based ratio.
Data on redistricting is in `data/` directory. Currently only available for German *Kreise* (containing reforms in NRW, Sachsen, Sachsen-Anhalt and Mecklenburg-Vorpommern).
Install like this:
pip install pandas-redistrict
## Usage
``` python
>>> df # Values indexed by German district identifiers
value1 value2
AGS
05354 4 5
05313 5 6
05334 6 7
15154 8 9
15159 10 11
15151 12 13
15082 13 14
>>> # Port old identifiers to new versions. Sum and distribute values on the way
>>> from redistrict import redistrict
>>> redistrict(df, 'de/kreise', drop=True, splits=True)
value1 value2
AGS
05334 15.00 18.00
15001 2.40 2.60
15082 35.44 38.81
15086 0.96 1.04
15091 4.20 4.55
```
When you want to preserve groups inside districts, you can use ``redistrict_grouped``:
``` python
>>> # Specify district column (e.g. AGS)
>>> # Also specify groups to preserve, in this case year
>>> df
AGS year value1 value2
0 05354 2008 4 5
1 05313 2008 5 6
2 05334 2011 6 7
3 15154 2005 8 9
4 15159 2005 10 11
5 15151 2005 12 13
6 15082 2013 13 14
>>> from redistrict import redistrict_grouped
redistrict_grouped(df, 'de/kreise', ['year'],
district_col='AGS',
value_cols=['value1', 'value2'],
drop=True)
AGS value1 value2 year
0 15001 2.40 2.60 2005
1 15082 22.44 24.81 2005
2 15086 0.96 1.04 2005
3 15091 4.20 4.55 2005
0 05334 9.00 11.00 2008
0 05334 6.00 7.00 2011
0 15082 13.00 14.00 2013
```
Metadata
Release files for pandas-redistrict 0.0.3
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 |
|---|---|---|---|---|
| pandas-redistrict-0.0.3.tar.gz | 41.9 kB | Without provenance | Details for pandas-redistrict-0.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pandas_redistrict-0.0.3-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for pandas_redistrict-0.0.3-py2.py3-none-any.whl |
Total release size: 85.1 kB
Release files / pandas-redistrict-0.0.3.tar.gz
| Download URL | pandas-redistrict-0.0.3.tar.gz |
|---|---|
| Size | 41.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0c37b7f69c5082525112760ae795288b9d46376e5ba42654e54c62212392b45f
|
|
BLAKE2b-256 checksum How to use checksums |
749d8447a3dd3e05eac83687420f7e3e07658df9d574d576c6c5b601829dbcd6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / pandas_redistrict-0.0.3-py2.py3-none-any.whl
| Download URL | pandas_redistrict-0.0.3-py2.py3-none-any.whl |
|---|---|
| Size | 43.2 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
5341ced47920ab6432228c3426022186c186f91983fbb5e397e5c3f2dee8029f
|
|
BLAKE2b-256 checksum How to use checksums |
5514ee5b95358f8c5833331b8f7d8bf6133855b6c7b6f3118e58ea0f38e4829c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for pandas-redistrict 0.0.3
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.