Skip to main content

🧬 dataframe-mutator

Production-grade mutation testing for Polars dataframes. Validate your test suite quality by automatically detecting which mutations (logic bugs) your tests actually catch.

Mutation testing runs your tests against intentionally mutated code. If tests pass despite the mutation, your test is weak. This framework makes it easy to find gaps in data pipeline test coverage.

Build Tests Coverage Operators Python License

⚡ Quick Start

Installation

pip install dataframe-mutator[polars]

2-Minute Example

import polars as pl
from dataframe_mutator.polars import SmartPolarsTestRunner

# Your pipeline
def process_sales(df: pl.DataFrame) -> pl.DataFrame:
    return (
        df
        .filter(pl.col("amount") > 100)
        .group_by("region")
        .agg(pl.col("amount").sum())
    )

# Test quality
tester = SmartPolarsTestRunner(test_command="pytest tests/")
results = tester.analyze_mutation_efficiency("pipeline.py")

print(f"High-value mutations: {results['high_value_mutations']}")
print(f"False positives avoided: {results['potential_false_positives_avoided']:.1f}%")

✨ Key Features

  • 109 Production Operators — Complete Polars API coverage (filtering, aggregations, joins, nulls, strings, datetime, window functions, and more)
  • Smart Analysis — AST-aware filtering eliminates false positives (6-10x faster than vanilla mutmut)
  • Real-World Bug Detection — Catches boundary errors, wrong aggregations, data loss, null handling mistakes, and boolean logic bugs
  • Easy Integration — Works with your existing pytest test suite

What It Catches

✅ Boundary mutations — > 0 → >= 0, >= 100 → > 100
✅ Aggregation swaps — sum() → mean(), count() → sum()
✅ Data loss bugs — inner_join() → left_join()
✅ Calculation errors — amount * 1.1 → amount * 1.0
✅ Boolean logic — & → |

How It Works

# 1. Quick analysis
tester.analyze_mutation_efficiency("src/pipeline.py")
# Returns: mutations found, false positives avoided, categories

# 2. Full mutation testing
results = tester.mutate_and_test("src/pipeline.py")
mutation_score = results['survival_rate']  # % of mutations caught

# 3. Interpret results
# 90-100% = Excellent
# 70-89%  = Good
# 50-69%  = Fair (add more tests)
# <50%    = Weak (significant gaps)

Examples & Documentation

Why Mutation Testing?

Traditional testing: Verifies expected behavior
Mutation testing: Verifies tests catch bugs when code changes

# Original code
if age > 18:
    adult = True

# Mutated code
if age >= 18:  # Bug: includes exactly 18-year-olds
    adult = True

# Traditional test: ✅ PASSES (doesn't test age==18)
# Mutation test: ❌ FAILS (catches the boundary change)

Integration with CI/CD

Works with GitHub Actions, GitLab CI, and other CI systems:

from dataframe_mutator.polars import SmartPolarsTestRunner

tester = SmartPolarsTestRunner(test_command="pytest tests/")
results = tester.analyze_mutation_efficiency("src/pipeline.py")

if results['high_value_mutations'] < 10:
    raise Exception("Insufficient test coverage")

Support

License

MIT — See LICENSE


Built for data scientists and engineers who need confidence in their data pipelines. 🚀

Metadata

Release files for dataframe-mutator 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dataframe-mutator 0.2.1
File Size Uploaded
dataframe_mutator-0.2.1.tar.gz 19.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dataframe-mutator 0.2.1
File Interpreter ABI Platform
dataframe_mutator-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 33.3 kB

Release files / dataframe_mutator-0.2.1.tar.gz

Download URL dataframe_mutator-0.2.1.tar.gz
Size 19.6 kB
Tags Source
SHA-256 checksum
How to use checksums
563d5838ccc883491bb2ddf15f0d873bcafea00d3f76ac42daf862e16f645a29
BLAKE2b-256 checksum
How to use checksums
ddc1d2f407e89eb054a8e2bfc945e7a42baad306bdb6c7046af0c3fc0235788f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / dataframe_mutator-0.2.1-py3-none-any.whl

Download URL dataframe_mutator-0.2.1-py3-none-any.whl
Size 13.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c7248f2c82b6f47f47ca5dc38b73bcbe35a67d0e262e20728af2f8022b77a99d
BLAKE2b-256 checksum
How to use checksums
a538138414747e019c8a91b6c74f11c7f55d2e552a2721e73a96e6e3172dc28e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page