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.1.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.1.1
File Size Uploaded
dataframe_mutator-0.1.1.tar.gz 11.7 kB Details

Built distribution (wheel)

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

Total release size: 16.4 kB

Release files / dataframe_mutator-0.1.1.tar.gz

Download URL dataframe_mutator-0.1.1.tar.gz
Size 11.7 kB
Tags Source
SHA-256 checksum
How to use checksums
a1e3e5179a8d945938a381a4036081c9b3d9e0b17356c0b989733986ff247e08
BLAKE2b-256 checksum
How to use checksums
a3f2e07e9c025ed726b8c6255a2956df8c04fd031e84fae9cb3ae5dd40d46460
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.1.1-py3-none-any.whl

Download URL dataframe_mutator-0.1.1-py3-none-any.whl
Size 4.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c988cdb451c7f650512f29e2fedda0488e0ccda5f6c2606cfc1dfd9500488332
BLAKE2b-256 checksum
How to use checksums
7a9c66045a00a94390923c6500a2df9a6ad397e6ee9216d83cb384d34a79ba06
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

0.2.1

2 release files

0.2.0

2 release files

This release

0.1.1 This release

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