Registry / analytics / microdf-python

microdf-python

JSON →
library1.3.0pypypi✓ verified 84d ago

Provides weighted pandas DataFrames and Series for survey microdata analysis. Current version 1.3.0, released periodically.

pip install microdf-python
INSTALL
IMPORT
SIG · MICRODF-PYTHON
M
microdf-python
analyticspythonv1.3.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

MicroDataFrame
from microdf import MicroDataFrame
import microdf; microdf.MicroDataFrame
Common mistake: importing the package instead of the class, causing AttributeError or verbose usage.
MicroSeries
from microdf import MicroSeries

Create a MicroDataFrame with a weight column and compute a weighted mean.

import pandas as pd from microdf import MicroDataFrame df = pd.DataFrame({ 'var1': [1, 2, 3, 4, 5], 'weight': [0.5, 1.0, 1.5, 0.5, 2.0] }) mdf = MicroDataFrame(df, weights='weight', weight_name='weight') print(mdf.weighted_mean('var1'))
Debug
Known issues
breakingIn version 1.0.0, the `weight_name` parameter became required; in earlier alpha versions it was optional. Omitting it now raises TypeError.
fix
Always pass `weight_name='your_weight_column'` when creating MicroDataFrame.
affects: >=1.0.0
gotchaWeights are applied to all operations, not just mean – e.g., `.std()` uses weighted standard deviation. Users expecting unweighted results on MicroDataFrame get different numbers.
fix
Convert to plain DataFrame with `mdf.to_dataframe()` if unweighted statistics are needed.
affects: all
deprecatedThe `from_frame` class method is deprecated in favor of directly calling `MicroDataFrame(df, ...)`. Using it still works but issues a FutureWarning.
fix
Replace `MicroDataFrame.from_frame(df, weights='w')` with `MicroDataFrame(df, weights='w', weight_name='w')`.
affects: >=1.2.0
Errors
Common errors & fixes
AttributeError: module 'microdf' has no attribute 'MicroDataFrame'
User imported the module incorrectly: `import microdf` then `microdf.MicroDataFrame` may fail if __init__.py doesn't export directly (but in this version it does, this error may happen if using old version or typo).
fix
Use `from microdf import MicroDataFrame`.
TypeError: __init__() missing 1 required positional argument: 'weight_name'
MicroDataFrame constructor requires `weight_name` parameter since v1.0.0.
fix
Provide the `weight_name` argument: `MicroDataFrame(df, weights='w', weight_name='w')`.
ValueError: Weights column not found in DataFrame
The column name passed to `weights` or `weight_name` does not exist in the DataFrame.
fix
Ensure the weight column is present and spelled correctly (case-sensitive).
Upgrade
Version history
1.3.0latest on PyPI · released Apr 17, 2026
Audit
Dependencies
pandasrequiredCore dependency for DataFrame operations.
numpyrequiredUsed internally for weighted calculations.
Agent activity
21 hits · last 30 days
node
20
OpenAI (training)
1
Resources

No resource links recorded.

microdf-python — pip install microdf-python · libregistry