Pandas transform checker
what is it ?
This library is focused on data quality checking on pandas transformations. Transformations are functions that takes a pandas DataFrame as input ( plus other params ) and output a DataFrame.
This library allow the user to specify a contract that the function must respect. In this contract the user can specify:
- the added columns
- the deleted columns
- the modified columns
- if the function add/drop records
- if the function modify the index ( ex: resampling )
Once the contract if specified, the function will raise a RuntimeError if one of it's specifications is violated.
how to use it ?
The package contains the decorator that performs the check it can be imported the following way:
from pandas_transform_checker.decorator_contract_checker import input_df_contract
Args
df_param: name of the param of the function that is the input df contract_params: dict defining the contract of the function in the following format:
contract_dict = {
"col_additions": {
"col_a": "int",
"col_b": "float"
},
"col_deletions": {
"col_c",
"col_d"
},
"col_editions": {
"col_e",
"col_f"
},
"allow_index_edition": False,
"allow_drop_record": True
}
which means that the function must create "col_a", "col_b", delete "col_c", "col_d", must not modify any column data except "col_e", "col_f", and must not edit the index
here is the list of keys allowed in this dict:
- col_additions: dict where keys are column names and values are dtypes (string)
- col_deletions: set of str representing the deleted columns
- col_editions: set of str representing the modified columns
- allow_index_edition: bool indicating if the function modify the index
- allow_add_drop_record (bool): indicate if the function can drop some records (ex. when dropna is used)
Usage
when you have a function that takes a df as input:
def super_func(df_input):
...
just add the annotation to automatically check properties
@input_df_contract(df_param="df_input", contract_dict={"col_editions": {"col_e","col_f"}})
def super_func(df_input):
...
Metadata
Release files for pandas-transform-checker 0.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 | Actions |
|---|---|---|---|---|
| pandas_transform_checker-0.1.1.tar.gz | 3.7 kB | Without provenance | Details for pandas_transform_checker-0.1.1.tar.gz |
Release files / pandas_transform_checker-0.1.1.tar.gz
| Download URL | pandas_transform_checker-0.1.1.tar.gz |
|---|---|
| Size | 3.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2a1f55f591d232353fe153b9da5cca410c0bb9b4f301852169534ed89b8769de
|
|
BLAKE2b-256 checksum How to use checksums |
c5c9d8b9e8afc30b0215589ab2677273b754c0e589e925e86d2b8f1ed451b88e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.7
|
Security for pandas-transform-checker 0.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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.