Skip to main content

Validata: A tool for data quality checks

A Python package to validate data quality for pandas DataFrames with flexible, configurable rules.


Features

  • Validate columns for numeric, date, string length, and outlier checks
  • Automatically generate a data quality report with examples of failures
  • Export results to CSV
  • Plug-and-play rule configuration for each column
  • Support for custom rules
  • Includes fuzz testing with Faker for robust testing

Rules

  • check for null (missing) values in a column
  • ensure the percentage of null (missing) values does not exceed a given threshold
  • ensure values in a column are unique
  • ensure values fall within a specified range
  • ensure all values are positive
  • ensure values match a given regex pattern
  • ensure column values are in a predefined set
  • ensure each value meets a minimum length
  • ensure each value does not exceed a maximum length
  • ensure valid email format
  • ensure that each value is numeric
  • ensure that value is among the specified values.
  • ensure that none of the values are in the disallowed list.
  • check if there are duplicate rows in the dataframe
  • check if any value contains leading or trailing spaces
  • check if values match a specific case format
  • check if a column contain only one unique value
  • check if values contain any special characters
  • check if a value contains only blank spaces
  • check for non-numeric values in a numeric column
  • Validates a dependency between two columns using a custom condition
  • check if DataFrame has exactly the expected column names
  • validate if columns match the expected data types.
  • validate if all values are alphabetic
  • validate if column values contain only alphanumeric characters

Installation

Clone this repository:

git clone https://github.com/your-username/validata.git
cd validata

Install dependencies:

pip install -r requirements.txt

(Optional) Install the package locally in editable mode:

pip install -e .

Project Structure

validata/
├── LICENSE
├── pyproject.toml
├── requirements.txt
├── README.md
├── src/
│   └── validata/
│       ├── __init__.py
│       ├── checker.py
│       └── rules.py
└── tests/
    ├── test_checker.py
    ├── test_rules.py
    └── test_faker.py

Usage

Import the package

import pandas as pd
from src.validata.checker import DataQualityChecker
from src.validata.rules import check_min_length, check_numeric, check_date_format, check_outliers_zscore

Prepare your dataframe

df = pd.DataFrame({
    "name": ["Alice", "Bo", "Charles", ""],
    "age": [25, "NaN", 40, 200],
    "dob": ["1990-01-01", "not-a-date", "1985-05-12", "2000-13-01"]
})

Define rules

rules = {
    "name": [check_min_length(3)],
    "age": [check_numeric(), check_outliers_zscore(2)],
    "dob": [check_date_format("%Y-%m-%d")]
}

Run the Checker

checker = DataQualityChecker(df)
results = checker.run(rules)

print(results)

Generate a Report

print(checker.generate_report())

Example Report

=== DATA QUALITY REPORT ===

Column: name
  - Min Length (3): FAIL | 2 values shorter than 3
    Examples of failures:
      Row 1: name = Bo
      Row 3: name = 

Column: age
  - Numeric Check: FAIL | 1 non-numeric value
    Examples of failures:
      Row 1: age = NaN
  - Outlier Z-Score (2): FAIL | 1 outlier detected
    Examples of failures:
      Row 3: age = 200

Column: dob
  - Date Format (%Y-%m-%d): FAIL | 2 invalid dates
    Examples of failures:
      Row 1: dob = not-a-date
      Row 3: dob = 2000-13-01

checker.export_report("validata_report.csv")

checker.export_report("validata_report.csv")

Testing

Run the full test suite

pytest -v

Run only rule test

pytest tests/test_rules.py -v or python -m pytest tests/test_rules.py -v


pytest tests/test_faker.py -v or python -m pytest tests/test_faker.py

Advanced Usage

Add a custom rule You can easily define a custom rule:

def check_no_nulls():
    def _check(series):
        failed = series[series.isnull()].index.tolist()
        return {
            "name": "No Nulls",
            "passed": len(failed) == 0,
            "message": f"{len(failed)} null values" if failed else "No nulls found",
            "failed_rows": failed
        }
    return _check

rules = {
    "name": [check_no_nulls()]
}

Development

Update dependencies in requirements.txt.

Add new rules in src/validata/rules.py.

Add tests in tests/.

Update README.md with new features.

Quick Start: ETL Pipeline Integration:

You can easily integrate DataqualityChecker into an ETL (Extract-Transform-Load) pipeline:

import pandas as pd
from src.validata.checker import DataQualityChecker
from src.validata.rules import check_min_length, check_numeric, check_date_format

def extract_data():
    # Example: Load from CSV
    return pd.read_csv("data/raw/customers.csv")

def transform_data(df):
    # Example: Clean column names and trim spaces
    df.columns = [c.strip().lower() for c in df.columns]
    return df

def validate_data(df):
    rules = {
        "name": [check_min_length(3)],
        "age": [check_numeric()],
        "dob": [check_date_format("%Y-%m-%d")]
    }

    checker = DataQualityChecker(df)
    checker.run(rules)

    print(checker.generate_report())

    # If any check fails, raise an error to stop the pipeline
    if any(not r["passed"] for results in checker.results.values() for r in results):
        raise ValueError("Data quality checks failed. See report above.")

    return df

def load_data(df):
    # Example: Save to processed folder
    df.to_csv("data/processed/customers_clean.csv", index=False)

if __name__ == "__main__":
    df = extract_data()
    df = transform_data(df)
    df = validate_data(df)
    load_data(df)

This structure allows:

Automatic validation before loading data

Integration with CI/CD pipelines

Failing fast if data quality issues are detected

Bad Data Example:

df = pd.DataFrame({
    "name": ["", "A", None],
    "age": ["NaN", "invalid", 9999],
    "dob": ["31-12-2020", "bad-date", None]
})

rules = {
    "name": [check_min_length(3)],
    "age": [check_numeric(), check_outliers_zscore(2)],
    "dob": [check_date_format("%Y-%m-%d")]
}

checker = DataQualityChecker(df)
checker.run(rules)
print(checker.generate_report())

if any(not r["passed"] for results in checker.results.values() for r in results):
    raise ValueError("Data quality validation failed.")

Output

=== DATA QUALITY REPORT ===

Column: name

  • Min Length (3): FAIL | 3 values shorter than 3 Examples of failures: Row 0: name = Row 1: name = A Row 2: name = None

Column: age

  • Numeric Check: FAIL | 2 non-numeric values Examples of failures: Row 0: age = NaN Row 1: age = invalid
  • Outlier Z-Score (2): FAIL | 1 outlier detected Examples of failures: Row 2: age = 9999

Column: dob

  • Date Format (%Y-%m-%d): FAIL | 3 invalid dates Examples of failures: Row 0: dob = 31-12-2020 Row 1: dob = bad-date Row 2: dob = None

ETL pipeline terminated due to data quality errors.

Metadata

Release files for datax-validator 0.1.3

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

Source distribution (sdist)

Source distribution for datax-validator 0.1.3
File Size Uploaded Provenance Actions
datax_validator-0.1.3.tar.gz 14.5 kB Without provenance Details for datax_validator-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for datax-validator 0.1.3
File Interpreter ABI Platform Actions
datax_validator-0.1.3-py3-none-any.whl Python 3 none any Details for datax_validator-0.1.3-py3-none-any.whl

Total release size: 28.0 kB

Release files / datax_validator-0.1.3.tar.gz

Download URL datax_validator-0.1.3.tar.gz
Size 14.5 kB
Tags Source
SHA-256 checksum
How to use checksums
bacc51cad3be23a00e9e18355d092a5b13d85361572f9880fab52f3e3e9c7f64
BLAKE2b-256 checksum
How to use checksums
329697f58f99a744575784ce0ceb659c8706c7484520c10ea2db2121397db401
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.6

Release files / datax_validator-0.1.3-py3-none-any.whl

Download URL datax_validator-0.1.3-py3-none-any.whl
Size 13.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4ad237f82be630880eafc3abef129d5a365b9fc084388f9830adb5f8783ba326
BLAKE2b-256 checksum
How to use checksums
736b9e941750d3ca457c2eb61e69c692bf58fb8dcb6b0b984a16ae95f178d739
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.6

Security for datax-validator 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files No provenance

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