Skip to main content

Production-grade data cleaning and validation pipeline

Project description

Data Cleaning Pipeline

Python 3.8+ License: MIT

A robust, beta-grade Python package for automating complex data cleaning workflows.

Features

  • 🛡️ Robust Validation: Validate data against YAML schemas and ensure type integrity.
  • 🧹 Advanced Cleaning:
    • Missing value imputation (Mean, Median, Mode, Fill)
    • Outlier detection (IQR, Z-Score, Isolation Forest)
    • Text standardization (Vectorized operations)
    • Duplicate removal
  • 🚀 High Performance:
    • Verified Scalability: Tested up to 5 Million rows.
    • Optimized: ~300k-500k rows/sec processing speed.
    • Chunking support for large datasets (> RAM)
  • 🔒 Secure & Safe:
    • Configurable rollback mechanism (Undo last 1-10 steps)
    • Path traversal protection
    • Safe execution context
  • 📊 Reporting:
    • Detailed JSON audit logs
    • Data quality scoring

Performance

We verified the pipeline's performance on datasets up to 5 Million rows:

  • 50,000 rows: ~0.12s
  • 2,000,000 rows: ~5.12s
  • 5,000,000 rows: ~16.25s (Tested on standard hardware, scales linearly)

Installation

pip install DataCleaningPipeline

Quick Start

import pandas as pd
from DataCleaningPipeline import DataCleaningPipeline, PipelineConfig

# 1. Load Data
df = pd.read_csv("dirty_data.csv")

# 2. Configure Pipeline
config = PipelineConfig(
    log_level="INFO",
    max_checkpoints=5,
    strict_mode=True
)

# 3. Clean!
pipeline = DataCleaningPipeline(df, config)

clean_df = (pipeline
    .remove_duplicates(subset=['id'])
    .handle_missing_values({'age': 'median', 'city': 'mode'})
    .standardize_text(['city', 'email'], lowercase=True)
    .remove_outliers(['salary'], method='isolation_forest')
    .validate_email('email', remove_invalid=True)
    .get_cleaned_data()
)

# 4. Export
pipeline.to_parquet("clean_data.parquet")
pipeline.export_report("audit_log.json")

Advanced Features

Chunked Processing (Large Files)

Process files larger than memory by streaming them in chunks:

pipeline = DataCleaningPipeline(pd.DataFrame(), config)
# Process large files in chunks (generator-based)
for chunk_pipeline in pipeline.process_in_chunks("huge_file.csv", chunk_size=50000):
    (chunk_pipeline
        .remove_duplicates()
        .handle_missing_values({'age': 'median'})
    ).to_csv("clean_output.csv", mode='a', header=False)

Schema Validation

Enforce strict data contracts using YAML schemas:

pipeline.validate_schema("schema.yaml", schema_name="customer_data")

Configuration

Control pipeline behavior via DataCleaningPipeline.config.PipelineConfig or config.yaml:

  • strict_mode: Raise exceptions instead of logging warnings.
  • Log Level: Set logging verbosity (DEBUG, INFO, WARNING, ERROR).
  • max_checkpoints: Control memory usage for rollback history.
  • max_memory_mb: Strict memory limit (MB) for creating checkpoints. Older checkpoints are dropped if limit is exceeded.
  • log_file: Enable file-based logging (JSON formatted).
  • strict_mode: Enforce strict error handling (raises PipelineError on failure).
  • allow_custom_functions: Enable/Disable apply_custom_function for security.
  • allow_file_operations: Enable/Disable file system access (restricted to CWD).

Security & Reliability features

  • Secure Logging: Logs are strictly formatted as JSON to prevent injection.
  • Path Traversal Protection: File operations are restricted to the Current Working Directory.
  • Memory Guardrails: Prevents Out-Of-Memory errors by actively managing checkpoint history size.
  • Input Validation: Strict validation for all configuration parameters.

License

MIT

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

datacleaningpipeline-2.1.1.tar.gz (25.4 kB view details)

Uploaded Source

Built Distribution

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

datacleaningpipeline-2.1.1-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

File details

Details for the file datacleaningpipeline-2.1.1.tar.gz.

File metadata

  • Download URL: datacleaningpipeline-2.1.1.tar.gz
  • Upload date:
  • Size: 25.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for datacleaningpipeline-2.1.1.tar.gz
Algorithm Hash digest
SHA256 c1da868be2f212e1d19b8d12a88e86d2700e706d3f9c4c31a04c17e120b80694
MD5 60339884c34e5e0ee7a511d5fdc00331
BLAKE2b-256 76abae5618e7eeddb6f6ec12ff397035e68eff42fbbbc5ead6162340e03bdb35

See more details on using hashes here.

File details

Details for the file datacleaningpipeline-2.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for datacleaningpipeline-2.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 379acc93a84d6ab112b9967d0d8b1667ad7f5c9467e87de5462b96eb89f7e3f0
MD5 d8c84d2910190f603991d6274926acd4
BLAKE2b-256 23eec35703ae3fbd37c72d0a29d10687367e376ec7a29c87312ccc43c1595d9f

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