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. The name of the dataframe is the variable name you give to the dataframe. Default value is "dataframe"

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

# import two datasets
df = sns.load_dataset("iris") 
#generate this dataset
df2 = pd.util.testing.makeMixedDataFrame()

# initialise the Module
quality = dq(df)
change = dq(df2)

#get row count
rows = quality.get_row_count()
print(rows)
print("")
# check data quality
quality.data_quality_check()
print("")
# generate the schema of df passed in the quality variable
quality.generate_schema()
print("")
# print schema
quality.print_schema()
print("")
# save schema
change.save_schema_to_file()
print("")
# Compare schema drift
## after you run the save_schema_to_file function then use the saved schema.json file
## test.json is iris dataset. and change is new dataset created
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")

#dq.dtype_columns(df)

#df.head()

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.1.tar.gz (6.1 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.1-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: data_quality_tests-3.1.tar.gz
  • Upload date:
  • Size: 6.1 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.1.tar.gz
Algorithm Hash digest
SHA256 360bd7e61a7e3f5e3e8d20adf172c9a3d4267f8689e1a87cc43aaf009cdb6cf7
MD5 18edb284b31e2b52e8d85f6f39f0e7c0
BLAKE2b-256 1db379c0591fab5e834704b6b9b60eced1ee5e6ca7ad5f791b34962c8169df7b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for data_quality_tests-3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4844bba85f33ef5451f981bd169e9e234a8ff14be972e11d6acdc4e2f38ef260
MD5 a13d20eb1580688008521ef01a8bf778
BLAKE2b-256 0d1fd6f28b38ab12b12089e40dec5223720d16e34f59c5b28933530922ece0ef

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