---
# System prepended metadata

title: Untitled

---

The following is for the data scientist to simply play around with transformations to see how it's affecting a sample data set:

```python
df = pd.DataFrame({
    "name": ["alice", "bob"],
    "age": [3, 4],
    "ssi": [12345, 67890],
})

from cape_privacy import types
from cape_privacy.pandas import ascii_charset
from cape_privacy.pandas import Tokenizer
from cape_privacy.pandas import DateTimePerturbator

tokenizer = Tokenizer(
    token_length=10,
    charset=ascii_charset,
    key=b"my secret",
)

pertubator = DateTimePerturbator(
    frequency=Months,
    lower=-6,
    upper=6,
)

df["name"] = df["name"].apply(tokenizer)
df["age"] = df["age"].apply(pertubator)
df.Drop("ssi")
```

When the data scientist is happy with how the data set is being transformed, they can write it up as a policy that's easily shared with others on the team:

```yaml
policy:
  version: 1

  transformations:
  - my_tokenizer:
    type: tokenizer
    token_length: 10
    charset: ascii
    key: "my secret"

  rules:
  - match:
    name: name
    actions:
    - transform:
      name: my_tokenizer
  - match:
    name: age
    actions:
    - transform:
      type: datetime_pertubator
      frequency: months
      range: [-6, 6]
  - match:
    name: ssi
    actions:
    - drop
```

Anyone can use this policy file to set up an identical pipeline:

```python
from cape_privacy import load_policy

policy = load_policy("gcs://site.com/file.yaml")
df = policy.apply(df)
```