A python package used for validating pandas dataframes.
Project description
pandas_validate
A python package used for validating pandas dataframes.
⚙️ Installation
python -m pip install pandas_validate
🚀 Usage
# Imports
import pandas as pd
from pandas_validate import Schema
from pandas_validate.columns import IntColumn, TextColumn
# Define your Schema
class MySchema(Schema):
IntField = IntColumn(min_value=3, max_value=10)
TextField = TextColumn(min_length=3, max_length=5, pattern="^[a-c]+$")
# Get your DataFrame
df = pd.DataFrame({
'IntField': [1, 6, 11, 7],
'TextField': ['ab', 'abcd', 'ccbbaa', 'ccb'],
'UnknownField': [1, 2, 3, 4]
})
# Validate your DataFrame
validated_df, exceptions = MySchema.validate(df)
Results
>>> print(validated_df)
IntField TextField
0 NaN None
1 6.0 None
2 NaN None
3 7.0 ccb
>>> print(exceptions)
column row value error error_details
0 IntField 0.0 1 Column validation failed The value 1 < 3
1 IntField 2.0 11 Column validation failed The value 11 < 10
2 TextField 0.0 ab Column validation failed The value ab is too short
3 TextField 1.0 abcd Column validation failed The value abcd does not match the regular expr...
4 TextField 2.0 ccbbaa Column validation failed The value ccbbaa is too long
5 UnknownField NaN None Unknown Column The column "UnknownField" is not in the Schema
Code Contributors
This project exists thanks to all the people who contribute. [Contribute].
🤝 Contributing
Contributions, issues and feature requests are welcome.
Feel free to check issues page if you want to contribute.
Check the contributing guide.
Author
👤 Larry Green
- Github: @larrygreen3
Show your support
Please ⭐️ this repository if this project helped you!
📝 License
Copyright © 2023 Larry Green.
This project is MIT licensed.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pandas-validate-1.0.0.tar.gz
(9.8 kB
view hashes)
Built Distribution
Close
Hashes for pandas_validate-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 719fe146c15a4b87e49ca89fcbef84002ba43aa47f7e014d20541b09c0ad1348 |
|
MD5 | a5542e8fdadd9f5354854f1fcc651c0a |
|
BLAKE2b-256 | 3e16adce8ddf3d8ad80dbb131b3298a330e21d412f8eda08b2803dc9c991a44b |