PyIPUMS
PyIPUMS is a library for working with data from IPUMS.
Example
Example that provides the IPUMS metadata in a dictionary.
import json
import pandas as pd
from src.pyipums.parse_xml import read_ipums_ddi
from ipumspy import readers, ddi
def read_ipums_micro(ddi, data_file_path, n_max=None):
# Read the fixed-width data file using the extracted column information
df = pd.read_fwf(
data_file_path,
dtypes=ddi["column_dtypes"],
colspecs=ddi["column_specs"],
header=None,
names=ddi["columns"],
nrows=n_max,
compression="gzip",
)
return df
def main():
ddi_file_path = "./usa_00003.xml"
data_file_path = "./usa_00003.dat.gz"
cps_ddi = read_ipums_ddi(ddi_file_path)
print(json.dumps(cps_ddi["file_metadata"], indent=2))
cps_data = read_ipums_micro(cps_ddi, data_file_path, n_max=100)
print(cps_data.head())
Modifying
If you are looking to make changes to the library I recommend using poetry.
poetry env use 3.8
pyenv shell 3.8
poetry shell
License
MIT
Metadata
Release files for pyipums 0.0.4
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 |
|---|---|---|---|---|
| pyipums-0.0.4.tar.gz | 6.1 kB | Without provenance | Details for pyipums-0.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyipums-0.0.4-py3-none-any.whl | Python 3 | none | any | Details for pyipums-0.0.4-py3-none-any.whl |
Total release size: 12.9 kB
Release files / pyipums-0.0.4.tar.gz
| Download URL | pyipums-0.0.4.tar.gz |
|---|---|
| Size | 6.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a70ee417feb09f74e9fabaee43bc3dfbfe7b0e95f5afcc950a5510af90c74cf5
|
|
BLAKE2b-256 checksum How to use checksums |
07b693881a815126aa348d109c4c5d445df00294cf5cd0e389bc60417e191a64
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.16
|
Release files / pyipums-0.0.4-py3-none-any.whl
| Download URL | pyipums-0.0.4-py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
068973eb4303a82ead02e4e4b5757f9a798982c9789264fce617d1f2b60f480c
|
|
BLAKE2b-256 checksum How to use checksums |
9d7d162595ee18be88c7c2a3b024bb8753c1cae5b40c0456f5cfddd9296d1968
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.16
|
Security for pyipums 0.0.4
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.