Skip to main content

Weighted pandas DataFrames and Series for survey microdata

Project description

Build Codecov

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."

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

microdf_python-1.3.0.tar.gz (28.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

microdf_python-1.3.0-py3-none-any.whl (28.9 kB view details)

Uploaded Python 3

File details

Details for the file microdf_python-1.3.0.tar.gz.

File metadata

  • Download URL: microdf_python-1.3.0.tar.gz
  • Upload date:
  • Size: 28.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for microdf_python-1.3.0.tar.gz
Algorithm Hash digest
SHA256 f352fe32c25a4fd6d6188ef6aaca0214b53b29a8a7913aca6af0362dd9c922bd
MD5 0a09c1f73151b5b286b9418a8a04af5a
BLAKE2b-256 a31ba4b6a53c8e6668c190e1928ebf9f8c67d6a4995ff4a4b0e3403ded30d4ab

See more details on using hashes here.

File details

Details for the file microdf_python-1.3.0-py3-none-any.whl.

File metadata

  • Download URL: microdf_python-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 28.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for microdf_python-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e17757a198648108eae24f39384e27b5ae8061acf1b43fa56520010dc00a7b55
MD5 d026f1dcc680c8f16b4a06081f03411a
BLAKE2b-256 b9aace692e0488b5e6c0943f52886cf6a15f5d9a6dee7744b190a3a1d67f5d6e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page