microdf
Weighted pandas DataFrames and Series for survey microdata analysis.
Overview
microdf provides MicroDataFrame and MicroSeries classes that extend pandas functionality with integrated weighting support, essential for accurate survey data analysis.
Key Features
- MicroDataFrame: A pandas DataFrame with an integrated weight column
- MicroSeries: A pandas Series with integrated weights
- Weighted operations: All aggregations (sum, mean, median, etc.) automatically use weights
- Inequality metrics: Built-in Gini coefficient calculation
- Poverty analysis: Integrated poverty rate and gap calculations
Installation
Install with:
pip install microdf-python
Or for development:
pip install git+https://github.com/PolicyEngine/microdf.git
Usage
import microdf as mdf
import pandas as pd
# Create sample data with weights
df = pd.DataFrame(
{"income": [10_000, 20_000, 30_000, 40_000, 50_000], "weights": [1, 2, 3, 2, 1]}
)
# Create a MicroDataFrame
mdf_df = mdf.MicroDataFrame(df, weights="weights")
# All operations are weight-aware
print(mdf_df.income.mean()) # Weighted mean
print(mdf_df.income.gini()) # Gini coefficient
Questions
Contact the maintainer, Max Ghenis (max@policyengine.org).
Citation
You may cite the source of your analysis as "microdf release #.#.#, author's calculations."
Metadata
Release files for microdf-python 1.4.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 | |
|---|---|---|---|
| microdf_python-1.4.1.tar.gz | 46.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| microdf_python-1.4.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 98.8 kB
Release files / microdf_python-1.4.1.tar.gz
| Download URL | microdf_python-1.4.1.tar.gz |
|---|---|
| Size | 46.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a2909d2c198ece3170d2a5cd07c3f080125a0cdba372c2a70bc90b90725275ef
|
|
BLAKE2b-256 checksum How to use checksums |
0a481ec070b473ea9e0c734ba1be05e48b37d1cf72fddff3608ba30a166e02c6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / microdf_python-1.4.1-py3-none-any.whl
| Download URL | microdf_python-1.4.1-py3-none-any.whl |
|---|---|
| Size | 52.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bfed592e45f4154247379b4b077262002f58574d311bd0f7b7628fef8fa7874f
|
|
BLAKE2b-256 checksum How to use checksums |
38f44952f9294ccf2407743c4e50232c99e4a89ed672273cd6f7426f723bfbba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|