Pandas accessor for replacing, removing, or encrypting a DataFrame or Series that contains Personally Identifiable Information (PII) or Protected Health Information (PHI)
Project description
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
Clean Type Options
encrypt
(default) - Utilizes the cryptography library and uses Fernet (symmetric encryption)- NOTE: You must use the
serialize_encryption_key
before 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. ReturnsNone
if 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"]})
>>> test_df.clean_pandas.clean_series('ssn')
0 b'gAAAAABbextrtJcQfOt37HK7pEISBokuh9ndWwGhvZpv...
1 b'gAAAAABbextrHo7qFr6DIZ0FlvVyO73HOmOYujKsv6vS...
Name: ssn, dtype: object
>>> test_df.clean_pandas.clean_series('last_name', clean_type='faker', faker_type='first_name')
0 Joshua
1 Michael
Name: last_name, dtype: object
>>> test_df.clean_pandas.clean_series('ssn', clean_type='scrubadub')
0 {{SSN}}
1 {{SSN}}
Name: ssn, dtype: object
>>> test_df.clean_pandas.clean_series('ssn', clean_type='truncate', trunc_length=7, trunc_from_end=False)
0 5555
1 6789
Name: ssn, dtype: object
Batch Clean
>>> cleaner_params = [{'series_name': 'last_name', 'clean_type': 'faker', 'faker_type': 'last_name'}, {'series_name': 'ssn', 'clean_type': 'scrubadub'}]
>>> test_df.clean_pandas.clean_dataframe(cleaner_params)
first_name last_name ssn
0 Charles Pacheco {{SSN}}
1 Stephen Hogan {{SSN}}
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.
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
Built Distributions
Hashes for clean_pandas-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ae49204f7d5237673c8a8793b01da525ae1805519e4e061961166b938914c3ec |
|
MD5 | 6655e536f85d1e42f268c2eaeb33ce8a |
|
BLAKE2b-256 | 69cc322e42a8b418c55d91a4783c2b6613ccd59e7eb093cbd774c7c4a9811e69 |