Skip to main content

VerifyData is an intuitive library focused on data quality assessment, offering automated checks for completeness, consistency, and accuracy to guarantee high standards across your data flows.

Project description

VerifyData

VerifyData is a Python package for performing data quality checks on PySpark DataFrames. It provides a comprehensive set of checks to validate the integrity, consistency, and accuracy of data before processing, ensuring that data meets the required standards. The package is ideal for ETL workflows, data pipelines, and any scenario where high-quality data is essential.

Features

  • Null Value Check: Ensures that specified columns do not contain null values.
  • Uniqueness Check: Verifies that the values in a specified column are unique.
  • Range Check: Checks if values in a column fall within a specified range.
  • Valid Values Check: Confirms that values in a column belong to a list of predefined valid values.
  • Schema Validation: Validates the presence of required columns and their data types.

Installation

To install DataQualityChecker, clone the repository and install dependencies:

pip install -r requirements.txt

Usage

Here’s how to use DataQualityChecker:

  1. Initialize SparkSession:

    from pyspark.sql import SparkSession
    
    spark = SparkSession.builder.appName("DataQualityCheckerExample").getOrCreate()
    
  2. Define DataFrame and Expected Schema: from pyspark.sql.types import StructType, StructField, IntegerType, StringType

    data = [(1, "John", 25, "M"), (2, "Jane", None, "F"), (3, "Alice", 35, None)]
    schema = StructType([
       StructField("id", IntegerType(), True),
       StructField("name", StringType(), True),
       StructField("age", IntegerType(), True),
       StructField("gender", StringType(), True)
     ])
    df = spark.createDataFrame(data, schema)
     
    expected_schema = {
       "id": IntegerType(),
       "name": StringType(),
       "age": IntegerType(),
       "gender": StringType()
     }
    
  3. Initialize DataQualityChecker:

    from verify_data.verify import VerifyData
    
    dq_checker = VerifyData(df, expected_schema)
    
  4. Run Checks:

    dq_checker.check_null_values()
    dq_checker.check_uniqueness("id")
    dq_checker.check_value_range("age", 20, 40)
    dq_checker.check_valid_values("gender", ["M", "F"])
    dq_checker.check_column_presence()
    dq_checker.check_column_data_types()
     
    results_df = dq_checker.run_checks()
    results_df.show(truncate=False)
    

Example Output

The output will be a DataFrame containing a summary of each check, with details on whether the check passed or failed:

Check Passed Details
Null check on column age False 1 null value found
Uniqueness check on column id True All values are unique
Range check for column age True All values within range
Valid values check for column gender False 1 invalid value found
Schema column presence check True All necessary columns are present
Data type check for column age True Data type matches

Running Tests

Run unit tests with unittest to verify the integrity of the DataQualityChecker:

python -m unittest discover

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

verifydata-0.0.7.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

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

verifydata-0.0.7-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file verifydata-0.0.7.tar.gz.

File metadata

  • Download URL: verifydata-0.0.7.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for verifydata-0.0.7.tar.gz
Algorithm Hash digest
SHA256 730868e0816f9d613ff31d9cae12db800f94fd67194f053cc28b4ffe02686fd4
MD5 12f66701fb88df2cb4fec9820a8c75e3
BLAKE2b-256 0f061f43c4e4a87533f5b8d604d0188df1908fe2c5344c6eb7c22aaf8d63d397

See more details on using hashes here.

File details

Details for the file verifydata-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: verifydata-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for verifydata-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 a277d18bc54a6ffceb460528b31c33307d03913d17b453d7dde36816e57339b9
MD5 874466b4b1f23e642cefabd2c7fac71b
BLAKE2b-256 2d5ad09cc118ccc9deb70c14f5b4ca6311a23801b654adde2c33260a705347cf

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