Package: cape-privacy
Cape PythonA Python library supporting data transformations and collaborative privacy policies, for data science projects in Pandas and Apache SparkSee below for instructions on how to get started or visit thedocumentation.Getting startedPrerequisitesPython 3.6 or above, and pipPandas 1.0+PySpark 3.0+ (if using Spark)Make(if installing from source)Install with pipCape Python is available through PyPi.pipinstallcape-privacySupport for Apache Spark is optional.  If you plan on using the library together with Apache Spark, we suggest the following instead:pipinstallcape-privacy[spark]We recommend running it in a virtual environment, such asvenv.Install from sourceIt is possible to install the library from source. This installs all dependencies, including Apache Spark:gitclonehttps://github.com/capeprivacy/cape-python.gitcdcape-python
makebootstrapUsage exampleThis example is an abridged version of the tutorial foundheredf=pd.DataFrame({"name":["alice","bob"],"age":[34,55],"birthdate":[pd.Timestamp(1985,2,23),pd.Timestamp(1963,5,10)],})tokenize=Tokenizer(max_token_len=10,key=b"my secret")perturb_numeric=NumericPerturbation(dtype=dtypes.Integer,min=-10,max=10)df["name"]=tokenize(df["name"])df["age"]=perturb_numeric(df["age"])print(df.head())# >>#          name  age  birthdate# 0  f42c2f1964   34 1985-02-23# 1  2e586494b2   63 1963-05-10These steps can be saved in policy files so you can share them and collaborate with your team:# my-policy.yamllabel:my-policyversion:1rules:-match:name:ageactions:-transform:type:numeric-perturbationdtype:Integermin:-10max:10seed:4984-match:name:nameactions:-transform:type:tokenizermax_token_len:10key:my secretYou can then load this policy and apply it to your data frame:# df can be a Pandas or Spark data framepolicy=cape.parse_policy("my-policy.yaml")df=cape.apply_policy(policy,df)print(df.head())# >>#          name  age  birthdate# 0  f42c2f1964   34 1985-02-23# 1  2e586494b2   63 1963-05-10You can see more examples and usagehereor in ourdocumentation.About Cape Privacy and Cape PythonCape Privacyhelps teams share data and make decisions for safer and more powerful data science. Learn more atcapeprivacy.com.Cape Python brings Cape's policy language to Pandas and Apache Spark. The supported techniques include tokenization with linkability as well as perturbation and rounding. You can experiment with these techniques programmatically, in Python or in human-readable policy files.Cape architectureCape is comprised of multiples services and libraries. You can use Cape Python as a standalone library, or you can integrate it with the Coordinator inCape Core, which supports user and policy management.Project status and roadmapCape Python 0.1.1 was released 24th June 2020. It is actively maintained and developed, alongside other elements of the Cape ecosystem.Upcoming features:Reversible tokenisation: allow reversing of tokenization to reveal the raw value.Policy audit logging: create logging hooks to allow audit logs for policy downloads and usage in Cape Python.Expand pipeline integrations: add Apache Beam, Apache Flink, Apache Arrow Flight or Dask integration as another pipeline we can support, either as part of Cape Python or in its own separate project.The goal is a complete data management ecosystem. Cape Privacy providesCape Coordinator, to manage policy and users. This will interact with the Cape Privacy libraries (such asCape Python) through a workers interface, and with your own data services through an API.Help and resourcesIf you need help using Cape Python, you can:View thedocumentation.Submit an issue.Talk to us on ourcommunity Slack.Please filefeature requestsandbug reportsas GitHub issues.CommunityContributingView ourcontributingguide for more information.Code of conductOurcode of conductis included on the Cape Privacy website. All community members are expected to follow it. Please refer to that page for information on how to report problems.LicenseLicensed under Apache License, Version 2.0 (seeLICENSEorhttp://www.apache.org/licenses/LICENSE-2.0). Copyright as specified inNOTICE.