Clean Pandas
Pandas accessor for replacing, removing, or encrypting a DataFrame or Series that contains Personally Identifiable Information (PII) or Protected Health Information (PHI)
Dependencies
Installation
pip install clean_pandas
Clean Type Options
encrypt(default) - Utilizes the cryptography library and uses Fernet (symmetric encryption)- NOTE: You must use the
serialize_encryption_keybefore ending your REPL or program in order to decrypt
- NOTE: You must use the
faker- Utilizes the Faker library and requires user denote the Faker "fake" to usescrubadub- Utilizes the Scrubadub library to detect and replace PIItruncate- Truncates the data by casting to a string, if possible, and recast to original type if possible. ReturnsNoneif truncation is longer than the value length. Returns the string value if cannot be cast back to original type
Basic Usage
>>> from clean_pandas import CleanPandas
>>> import pandas as pd
>>> test_df = pd.DataFrame({"first_name": ["Charles", "Stephen"],
"last_name": ["Darwin", "Hawking"],
"ssn": ["555-55-5555", "123-45-6789"]})
>>> result_df, encryption_key, dtype_dict = test_df.clean_pandas.encrypt('ssn')
>>> result_df['ssn']
0 b'gAAAAABbextrtJcQfOt37HK7pEISBokuh9ndWwGhvZpv...
1 b'gAAAAABbextrHo7qFr6DIZ0FlvVyO73HOmOYujKsv6vS...
Name: ssn, dtype: object
>>> test_df.clean_pandas.fake_it('last_name', faker_type='first_name')['last_name']
0 Joshua
1 Michael
Name: last_name, dtype: object
>>> test_df.clean_pandas.scrub_it('ssn')['ssn']
0 {{SSN}}
1 {{SSN}}
Name: ssn, dtype: object
>>> test_df.clean_pandas.truncate('ssn', trunc_length=7, trunc_from_end=False)['ssn']
0 5555
1 6789
Name: ssn, dtype: object
# Decrypt a series
>>> result_df, encryption_key, dtype_dict = test_df.clean_pandas.encrypt('ssn') # encrypt
>>> test_df.some_id
0 b'gAAAAABblA1SIGqKbTC97RjEibmB4FBHnXqKVocvFMg4...
1 b'gAAAAABblA1Sc_StggFPj0zmQLUVo0ADqHQtljUEGcr0...
Name: some_id, dtype: object
# Automatically casts back to original dtype with optional dtype argument
>>> result_df.clean_pandas.decrypt('some_id', encryption_key, dtype_dict)['some_id']
0 1
1 2
Name: some_id, dtype: int64
License
MIT License
Copyright (c) 2018 Aaron Burgess
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Metadata
Release files for clean-pandas 1.0.0
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 |
|---|---|---|---|---|
| clean_pandas-1.0.0.tar.gz | 6.7 kB | Without provenance | Details for clean_pandas-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| clean_pandas-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for clean_pandas-1.0.0-py3-none-any.whl |
Total release size: 14.9 kB
Release files / clean_pandas-1.0.0.tar.gz
| Download URL | clean_pandas-1.0.0.tar.gz |
|---|---|
| Size | 6.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fbb0d120f1a2c110eadbbdfa0a45b49a2e68992cf5d34327bfe1af38b9277fb2
|
|
BLAKE2b-256 checksum How to use checksums |
0f032263e62fa5088d215c6078b53667c0496e4671925bffa4d806204b432ac0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.6
|
Release files / clean_pandas-1.0.0-py3-none-any.whl
| Download URL | clean_pandas-1.0.0-py3-none-any.whl |
|---|---|
| Size | 8.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3443d26f1bd93640ab78c43d34717b6f55ceb799d23df4e964bb815f018d819e
|
|
BLAKE2b-256 checksum How to use checksums |
0525ef2a686f5beb8d1fa83e24beafcc6e77a26b8d94d6ead172c306b672650c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.6
|
Security for clean-pandas 1.0.0
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.