DATA QUALITY
A library which acts as a test cases for dataframes, and other quality checks
The test cases include(as of now)
- check for null values
- check for duplicates
- check for dtype matching
Quality checks include(as of now)
- 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
-
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.
-
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 -
data_quality_check()now checks for column header whitespaces for leading and trailing. -
generate_schema()now generates a schema for any dataframe -
print_schema()prints the schema of a dataframe -
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" -
compare_with_schema(reference_schema)compares a current schema with already existing schema of your dataframe to check for schema drift.
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()
Metadata
Release files for data-quality-tests 3.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| data_quality_tests-3.1.1.tar.gz | 6.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| data_quality_tests-3.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.5 kB
Release files / data_quality_tests-3.1.1.tar.gz
| Download URL | data_quality_tests-3.1.1.tar.gz |
|---|---|
| Size | 6.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
29e2c4940272bb4245d36cfd81743a737cd94a85b5d7362f66fea336217f03bd
|
|
BLAKE2b-256 checksum How to use checksums |
054cefe1664d52d14f4a15631394df3810d9b6f576c68733e4307db62fbb60ea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / data_quality_tests-3.1.1-py3-none-any.whl
| Download URL | data_quality_tests-3.1.1-py3-none-any.whl |
|---|---|
| Size | 6.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
372ec96654b4b01a5373b30fcc7340749f48f3658012ec2800bbf1f1994de1a7
|
|
BLAKE2b-256 checksum How to use checksums |
6419308888ed28acbc453adebe395c9e591e660ce88016fe62fbd690077cfd20
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Security for data-quality-tests 3.1.1
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.