-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: docs and ci improvements (#3)
- Loading branch information
Showing
7 changed files
with
76 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
.DEFAULT_GOAL := help | ||
.DEFAULT_GOAL := all | ||
sources = src tests | ||
|
||
.PHONY: .poetry # Check that poetry is installed | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,58 @@ | ||
# pandas-validity | ||
[](https://pypi.org/project/pandas-validity/) | ||
 | ||
[](https://github.com/ohmycoffe/pandas-validity/actions/workflows/test.yaml?query=branch%3Amain) | ||
[](https://codecov.io/gh/ohmycoffe/organize-photos) | ||
[](https://github.com/ohmycoffe/pandas-validity/actions/workflows/test.yml?query=branch%3Amain) | ||
[](https://codecov.io/gh/ohmycoffe/pandas-validity) | ||
[](https://github.com/psf/black) | ||
[](https://mypy-lang.org/) | ||
[](https://python-poetry.org/) | ||
 | ||
|
||
## What is it? | ||
**pandas-validity** is a Python library for validation of pandas DataFrames. It provides a `DataFrameValidator` class that serves as a context manager. Within this context, you can perform multiple validations and checks. Any encountered errors are collected and raised at the end of the process. The `DataFrameValidator` raises a `ValidationErrorsGroup` exception to summarize the errors. | ||
|
||
## Where to get it? | ||
**pandas-validity** is a Python library for the validation of pandas DataFrames. It provides a `DataFrameValidator` class that serves as a context manager. Within this context, you can perform multiple validations and checks. Any encountered errors are collected and raised at the end of the process. The `DataFrameValidator` raises a `ValidationErrorsGroup` exception to summarize the errors. | ||
|
||
## Installation | ||
|
||
You can easily install the latest released version using binary installers from the [Python Package Index (PyPI)](https://pypi.org/project/pandas-validity): | ||
|
||
```sh | ||
pip install pandas-validity | ||
``` | ||
|
||
### Development Installation | ||
|
||
**Prerequisites**: [poetry](https://python-poetry.org/) for environment management | ||
|
||
The source code is currently hosted on GitHub at [ohmycoffe/pandas-validity](https://github.com/ohmycoffe/pandas-validity). To get the development version: | ||
|
||
```shell | ||
git clone [email protected]:ohmycoffe/pandas-validity.git | ||
``` | ||
|
||
To install the project and development dependencies: | ||
|
||
```shell | ||
make install | ||
``` | ||
|
||
To run tests: | ||
|
||
```shell | ||
make test | ||
``` | ||
|
||
To view all possible commands, use: | ||
|
||
```shell | ||
make help | ||
``` | ||
|
||
## Usage | ||
```python | ||
import pandas as pd | ||
import datetime | ||
from pandas_validity.validator import DataFrameValidator | ||
from pandas_validity import DataFrameValidator | ||
|
||
# Create a sample DataFrame | ||
df = pd.DataFrame( | ||
|
@@ -54,6 +85,7 @@ with DataFrameValidator(df) as validator: | |
``` | ||
|
||
**Output:** | ||
|
||
```shell | ||
Error occurred: (<class 'pandas_validity.exceptions.ValidationError'>) The dataframe has missing columns: ['E'] | ||
Error occurred: (<class 'pandas_validity.exceptions.ValidationError'>) The dataframe has redundant columns: ['D'] | ||
|
@@ -72,6 +104,12 @@ Error occurred: (<class 'pandas_validity.exceptions.ValidationError'>) Found 1 m | |
| pandas_validity.exceptions.ValidationError: Found 1 missing value: [{'index': 1, 'column': 'B', 'value': None}] | ||
+------------------------------------ | ||
``` | ||
--- | ||
|
||
The library supports the following data types for validation: | ||
- predefined: `"str"`, `"int"`, `"float"`,`"datetime"`, `"bool"` | ||
- or any `Callable` that accepts a data `type/dtype` object and returns a boolean value to indicate the validation status - example: `pd.api.types.is_string_dtype` | ||
|
||
|
||
## Development | ||
**Prerequisites**: [poetry](https://python-poetry.org/) for environment management | ||
|
@@ -82,7 +120,7 @@ The source code is currently hosted on GitHub at: | |
```shell | ||
git clone [email protected]:ohmycoffe/pandas-validity.git | ||
``` | ||
To install project and development dependencies: | ||
To install the project and development dependencies: | ||
```shell | ||
make install | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,32 @@ | ||
[build-system] | ||
requires = ["poetry-core>=1.0.0"] | ||
build-backend = "poetry.core.masonry.api" | ||
|
||
[tool.poetry] | ||
name = "pandas-validity" | ||
version = "0.1.0" | ||
version = "0.1.1" | ||
description = "Validation library for Pandas Dataframe" | ||
authors = ["ohmycoffe <[email protected]>"] | ||
readme = "README.md" | ||
packages = [{include = "pandas_validity", from = "src"}] | ||
license = "MIT" | ||
repository = "https://github.com/ohmycoffe/pandas-validity" | ||
keywords = ["pandas", "dataframe", "validation"] | ||
classifiers = [ | ||
"Development Status :: 3 - Alpha", | ||
"Environment :: Console", | ||
"Intended Audience :: Developers", | ||
"Intended Audience :: Science/Research", | ||
"Operating System :: OS Independent", | ||
"Programming Language :: Python", | ||
"Programming Language :: Python :: 3", | ||
"Programming Language :: Python :: 3.9", | ||
"Programming Language :: Python :: 3.10", | ||
"Programming Language :: Python :: 3.11", | ||
"Topic :: Software Development :: Libraries", | ||
"License :: OSI Approved :: MIT License", | ||
] | ||
|
||
|
||
[tool.poetry.dependencies] | ||
python = "^3.9" | ||
|
@@ -37,16 +59,13 @@ types-setuptools = "^68.2.0.0" | |
black = "^23.7.0" | ||
isort = "^5.12.0" | ||
|
||
[build-system] | ||
requires = ["poetry-core>=1.0.0"] | ||
build-backend = "poetry.core.masonry.api" | ||
|
||
[tool.isort] | ||
profile = "black" | ||
|
||
[tool.flake8] | ||
max-line-length = 88 | ||
extend-ignore = "E203" | ||
exclude = ['src/pandas_validity/__init__.py'] | ||
|
||
[tool.bandit.assert_used] | ||
skips = ['tests/**/*.py', 'tests/*.py'] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .validator import DataFrameValidator as DataFrameValidator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters