microdf

Compute weighted statistics and inequality metrics from survey microdata.

31|6|Updated Oct 19, 2025
One-click install
npx skills add https://github.com/PolicyEngine/policyengine-claude --skill microdf
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: microdf
Source: https://github.com/PolicyEngine/policyengine-claude/tree/main/skills/microdf-skill
Command: npx skills add https://github.com/PolicyEngine/policyengine-claude --skill microdf

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires microdf-python, pandas.

What problem does it solve?

Analyzing survey microdata often requires handling weighted observations for accurate statistics, inequality metrics, and poverty calculations. MicroDF simplifies these complex operations, ensuring your analysis reflects the true population distribution.

Core Features & Use Cases

  • Weighted Statistics: Calculate accurate means, medians, sums, and standard deviations for weighted data.
  • Inequality Metrics: Easily compute Gini coefficients and top X% income shares.
  • Poverty Analysis: Determine poverty rates, poverty gaps, and deep poverty rates.
  • Use Case: Calculate the Gini coefficient and poverty rate for a simulated population of households, using their weighted income data to understand the distributional impact of a policy.

Quick Start

Use the microdf skill to calculate the weighted mean income and Gini coefficient from your df DataFrame with a weights column.

Frequently Asked Questions about microdf

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I calculate weighted statistics from survey data with pandas?

Weighted statistics account for survey design by adjusting each observation's contribution based on its weight. MicroDF computes weighted means, medians, sums, and standard deviations directly from a pandas DataFrame with a weights column, ensuring results reflect the true population distribution.

What's the best way to compute poverty rates and inequality metrics from microdata?

Poverty analysis requires weighted calculations across survey samples to avoid bias. MicroDF provides purpose-built APIs for poverty rates, poverty gaps, deep poverty rates, and inequality metrics like Gini coefficients, all computed with proper weight handling on your microdata.

Can I calculate Gini coefficients and income distribution analysis on weighted survey samples?

Yes. MicroDF computes Gini coefficients, top X% income shares, decile values, and quantiles directly from weighted microdata. These inequality metrics automatically apply survey weights, giving accurate distributional insights for policy analysis.

Do I need specialized tools to handle weighted observations in survey analysis?

Standard pandas operations don't account for survey weights. MicroDF extends pandas with weight-aware methods through MicroDataFrame and MicroSeries APIs, eliminating manual weighting logic and reducing calculation errors in poverty and inequality analysis.

How do weighted survey results integrate with policy impact modeling?

MicroDF integrates with PolicyEngine results, allowing you to layer weighted microdata analysis on top of policy simulations. This combines survey microdata calculations with policy scenarios to measure distributional impacts on weighted populations.