PYTHON LIBRARY FOR ANONYMIZATION
This library supports the application of three classical anonymization techniques for tabular data: k-anonymity, l-diversity and t-closeness.
Installation
We recommend to use Python3 with virtualenv:
> virtualenv .venv -p python3
> source .venv/bin/activate
Then run the following command to install the library and all its requirements:
pip install python-anonymity
Documentation
The python-anonymity documentation is hosted on Read the Docs.
Getting started
Example using the crime synthetic dataset:
> import pandas as pd
> import pycanon
> from anonymity import tools
> from anonymity.tools.utils_k_anon import utils_k_anonymity as utils
>
> d = {
> "name": ["Joe", "Jill", "Sue", "Abe", "Bob", "Amy"],
> "marital stat": [
> "Separated",
> "Single",
> "Widowed",
> "Separated",
> "Widowed",
> "Single",
> ],
> "age": [29, 20, 24, 28, 25, 23],
> "ZIP code": ["32042", "32021", "32024", "32046", "32045", "32027"],
> "crime": ["Murder", "Theft", "Traffic", "Assault", "Piracy", "Indecency"],
> }
> data = pd.DataFrame(data=d)
>
> ID = ["name"]
> QI = ["marital stat", "age", "ZIP code"]
> SA = ["crime"]
> age_hierarchy = {"age": [0, 2, 5, 10]}
> hierarchy = {
> "marital stat": [
> ["Single", "Not married", "*"],
> ["Separated", "Not married", "*"],
> ["Divorce", "Not married", "*"],
> ["Widowed", "Not married", "*"],
> ["Married", "Married", "*"],
> ["Re-married", "Married", "*"],
> ],
> "ZIP code": [
> ["32042", "3204*", "*"],
> ["32021", "3202*", "*"],
> ["32024", "3202*", "*"],
> ["32046", "3204*", "*"],
> ["32045", "3204*", "*"],
> ["32027", "3202*", "*"],
> ],
> }
>
> mix_hierarchy = dict(hierarchy, **utils.create_ranges(data, age_hierarchy))
> k = 2
> supp_threshold = 0
> new_data = tools.data_fly(data, ID, QI, k, supp_threshold, self.mix_hierarchy)
>
License: Apache 2.0.
Note: the library is under heavy production, only for testing purposes.
Metadata
Release files for python-anonymity 0.0.1.post1
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 |
|---|---|---|---|---|
| python_anonymity-0.0.1.post1.tar.gz | 28.0 MB | Without provenance | Details for python_anonymity-0.0.1.post1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| python_anonymity-0.0.1.post1-py3-none-any.whl | Python 3 | none | any | Details for python_anonymity-0.0.1.post1-py3-none-any.whl |
Total release size: 36.5 MB
Release files / python_anonymity-0.0.1.post1.tar.gz
| Download URL | python_anonymity-0.0.1.post1.tar.gz |
|---|---|
| Size | 28.0 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d1364fd982cb1ac68aff8b3e90b5e482a975ef8808698fe7ba612b8e49e70ec2
|
|
BLAKE2b-256 checksum How to use checksums |
f1c36a499159e5c8fae3939096d7bc1daf9fe4a305acbc7b7fb33d1bec1c1174
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.8
|
Release files / python_anonymity-0.0.1.post1-py3-none-any.whl
| Download URL | python_anonymity-0.0.1.post1-py3-none-any.whl |
|---|---|
| Size | 8.4 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7e9ace7534a579b7310a3a10555924668b0e7303e7db113af7bded6c8cd1d522
|
|
BLAKE2b-256 checksum How to use checksums |
961e2aad7e56d274d13e1eda947262b389dd220d33bd5379b05370bd75f2fee6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.8
|
Security for python-anonymity 0.0.1.post1
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.