Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
python-version: '3.13'
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: "latest"
- name: Install dependencies
run: |
uv pip install -e ".[dev,taxcalc]" --system
uv pip install -e ".[dev]" --system
- name: Run tests
run: make test

Expand All @@ -37,14 +37,14 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
python-version: '3.13'
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: "latest"
- name: Install dependencies
run: |
uv pip install -e ".[dev,docs,taxcalc]" --system
uv pip install -e ".[dev,docs]" --system
- name: Build Jupyter Book
shell: bash -l {0}
run: |
Expand Down Expand Up @@ -77,7 +77,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
python-version: '3.13'
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
python-version: '3.13'
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
Expand All @@ -30,7 +30,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v4
Expand All @@ -45,7 +45,7 @@ jobs:
version: "latest"
- name: Install dependencies
run: |
uv pip install -e ".[dev,taxcalc]" --system
uv pip install -e ".[dev]" --system
- name: Run tests with coverage
run: make test
- name: Upload coverage to Codecov
Expand All @@ -64,14 +64,14 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
python-version: '3.13'
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: "latest"
- name: Install dependencies
run: |
uv pip install -e ".[dev,docs,taxcalc]" --system
uv pip install -e ".[dev,docs]" --system
- name: Build Jupyter Book
run: |
jb build docs/.
Expand Down
43 changes: 37 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,49 @@
[![Build](https://github.com/PSLmodels/microdf/workflows/Build%20and%20test%20[Python%203.7,%203.8,%203.9]/badge.svg)](https://github.com/PSLmodels/microdf/actions?query=workflow%3A%22Build+and+test+%5BPython+3.7%2C+3.8%2C+3.9%5D%22)
[![Codecov](https://codecov.io/gh/PSLmodels/microdf/branch/master/graph/badge.svg)](https://codecov.io/gh/PSLmodels/microdf)
[![Build](https://github.com/PolicyEngine/microdf/workflows/Pull%20request/badge.svg)](https://github.com/PolicyEngine/microdf/actions)
[![Codecov](https://codecov.io/gh/PolicyEngine/microdf/branch/master/graph/badge.svg)](https://codecov.io/gh/PolicyEngine/microdf)

# microdf
Analysis tools for working with survey microdata as DataFrames.
Weighted pandas DataFrames and Series for survey microdata analysis.

*Disclaimer: `MicroSeries` and `MicroDataFrame` are experimental features and may not consider weights after performing some operations. See open issues.*
## 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 git+git://github.com/PSLmodels/microdf.git
pip install microdf-python

Or for development:

pip install git+https://github.com/PolicyEngine/microdf.git

## Usage
```python
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 (mghenis@gmail.com).
Contact the maintainer, Max Ghenis (max@policyengine.org).

## Citation
You may cite the source of your analysis as "microdf release #.#.#, author's calculations."
16 changes: 16 additions & 0 deletions changelog_entry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
- bump: major
changes:
removed:
- Remove all modules not used by PolicyEngine repositories.
- Keep only MicroDataFrame, MicroSeries, and their GroupBy classes.
- Remove agg, concat, constants, custom_taxes, income_measures, inequality (standalone functions), io, poverty (standalone functions), tax, ubi, utils, and weighted modules.
- Remove _optional module as it's no longer needed.
- Remove associated test files for deleted modules.
- Simplify package to focus on core weighted data structures used by PolicyEngine.
changed:
- Update package description to reflect focused scope on weighted DataFrames and Series.
- Update README with clearer documentation and usage examples.
- Version bumped to 1.0.0 to reflect major breaking changes.
- Remove pip from dev dependencies as it's not needed.
- Update to Python 3.13 as main version, supporting Python 3.9+.
- Test against Python 3.9, 3.10, 3.11, 3.12, and 3.13 in CI.
Loading