polars_ipums
A package to work with IPUMS microata in Python. Used in-house at Opportunity Insights.
Example
# convert IPUMS microdata export to a hive-partioned Parquet dataset
import polars as pl
from polars_ipums import create_parquet_dataset
input_path = "~/Downloads/ipums_export"
output_path = "~/Desktop/parquet_ipums"
labels = {
# use the default IPUMS labels for the sex column
"sex": {},
# use custom labels for the race/hispanic origin column
"rachsing": {
"White": "White",
"Black/African American": "Black",
"American Indian/Alaska Native": "AIAN",
"Asian/Pacific Islander": "Asian",
"Hispanic/Latino": "Hispanic",
},
}
# give a few columns more human-readable names
renames = {
"rachsing": "race",
"countyfip": "county",
"ftotinc": "family_income",
"hhincome": "household_income",
}
# custom education column!
educd = pl.col("educd")
my_education = (
pl.when(educd.le(61))
.then(0)
.when(educd.is_between(62, 64))
.then(1)
.when(educd.is_between(65, 100))
.then(2)
.when(educd.is_between(101, 116))
.then(3)
.alias("my_education")
)
create_parquet_dataset(
input_path,
output_path,
labels=labels,
partition_by=["year"],
renames=renames,
additional_columns=[my_education],
override_output=True,
verbose=True,
)
# load a few rows back into memory
ipums_microdata = (
pl.scan_parquet(output_path / "**/*.parquet", hive_partitioning=True)
.head()
.collect()
)
Metadata
Release files for polars_ipums 0.0.1
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 |
|---|---|---|---|---|
| polars_ipums-0.0.1.tar.gz | 5.6 kB | Without provenance | Details for polars_ipums-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| polars_ipums-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for polars_ipums-0.0.1-py3-none-any.whl |
Total release size: 12.3 kB
Release files / polars_ipums-0.0.1.tar.gz
| Download URL | polars_ipums-0.0.1.tar.gz |
|---|---|
| Size | 5.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
023364e25929a440fa88eb91855000b44bf5ae9e8a80c893c94f6dd3a0e892d2
|
|
BLAKE2b-256 checksum How to use checksums |
0dfbcff977372cc836f69cb20de96a0e2cf5a6e46a05ce7da3e96900bdc01704
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.5.23
|
Release files / polars_ipums-0.0.1-py3-none-any.whl
| Download URL | polars_ipums-0.0.1-py3-none-any.whl |
|---|---|
| Size | 6.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
78c3dd52d36bfa91be37771fb29103133e2a386a52d31e397ce1eecfa8a0c838
|
|
BLAKE2b-256 checksum How to use checksums |
42f7da44da173749206e205e19fb1bb01717f5ad67afca8e1ca76aa09a220ab7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.5.23
|
Security for polars_ipums 0.0.1
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.