Skip to main content

Data Quality Check Library

Project description

DATA QUALITY

A library which acts as a test cases for dataframes, and other quality checks

The test cases include(as of now)

  1. check for null values
  2. check for duplicates
  3. check for dtype matching

Quality checks include(as of now)

  1. generate, save and compare dataframe schemas

The test cases work as a Pass/Fail type, where Passed indicates, good data quality and Failed indicates bad data quality.

The dataframe schema is useful to check for possible schema drifts in your data pipelines.

Example:

TEST CASE FOR NULL VALUES: Passed means that the dataframe has no null values. Failed indicates otherwise.

Requirements

  • Python 3+
  • Pandas
  • Numpy
  • json
  • datetime
  • Dict
  • typing

Installation

pip install data-quality-tests

Updates & Changes

  1. Usage of functions within the library has changed. previous you had to pass the dataframe to each function of the library. Now you simple have to pass it when initialising the module. Check get started section.

  2. new function get_row_count() has been added in this update, which displays number of rows in a dataframe.
    For use case, refer to the get started section

  3. data_quality_check() now checks for column header whitespaces for leading and trailing.

  4. generate_schema() now generates a schema for any dataframe

  5. print_schema() prints the schema of a dataframe

  6. save_schema_to_file() saves the current dataframe schema to a file. You have to create a file and use it's path.

Get Started

How to use this library:

Data quality check

The most basic usage of this library, here for simplifiction,
let's just se the iris dataset from seaborn library as df. And to compare it to another dataframe for schema drift lets generate a dataframe.

You can use any dataset.

from data_quality_tests import DataQuality as dq
import pandas as pd
import seaborn as sns
import json

df = sns.load_dataset("iris")
df2 = pd.util.testing.makeMixedDataFrame()

quality = dq(df)
change = dq(df2)

rows = quality.get_row_count()
print(rows)
print("")
quality.data_quality_check()
print("")
quality.generate_schema()
print("")
quality.print_schema()
print("")
quality.save_schema_to_file()
print("")
with open('test.json', 'r') as f:
    reference_schema = json.load(f)
diff = change.compare_with_schema(reference_schema)
if diff.get("status") != "Schemas are identical":
    print("Schema drift detected!")
    print(diff)
else:
    print("Schema is same")

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

data_quality_tests-3.0.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

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

data_quality_tests-3.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file data_quality_tests-3.0.tar.gz.

File metadata

  • Download URL: data_quality_tests-3.0.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for data_quality_tests-3.0.tar.gz
Algorithm Hash digest
SHA256 5821988e944677c5c835d8b584b8faacefc81635a6a2a90ffb6f9285e22ef5f9
MD5 4f3aa906ea5f342f6bbca28216df5fa4
BLAKE2b-256 2c302c0b1248f5e9b27740b99c3cca5a8b6679fb775e2e0ee86fb0f0813978c0

See more details on using hashes here.

File details

Details for the file data_quality_tests-3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for data_quality_tests-3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 225690c9b34f67b8de0681cbdabef4b964fb7fcf7313792050cebf8884ec52b0
MD5 6cf8c6dc5f0103f0f391827bde91469d
BLAKE2b-256 7f9b9b0977d674771365c8597a0a8e4ef9b2b8a1081ad9d6593d1e03ff29b00f

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