triplex-python
Triplex Analytics in plain Python: infer and check schema contracts, anonymize a table, generate
synthetic data. No notebook, no browser, no server. The engine is the same native code the
triplex command line runs.
Not published yet. Install from a source checkout (needs the Rust toolchain):
cd packages/triplex-python
pip install maturin
maturin develop --release
Use
import pandas as pd
import triplex
# 1. Check the raw export against the contract you keep in version control.
raw = pd.read_csv("customers.csv")
report = triplex.validate(raw, "customers.triplex.yaml")
if not report["valid"]:
raise SystemExit(report["errors"])
# 2. Your own pandas work: clean, filter, derive, drop.
df = raw.dropna(subset=["email"])
df = df[df["plan"] != "free"]
df["age_band"] = (df["age"] // 10) * 10
df = df.drop(columns=["signup_date"])
# 3. See what the table holds now: types, null rates, likely identifiers.
schema = triplex.infer_schema(df)
# 4. Generate a synthetic copy for tests or a demo.
run = triplex.synthesize(df, rows=1000, seed=1)
synthetic = run.table.to_pandas()
run.report["leakage"]
| Function | What it does |
|---|---|
infer_schema(data) |
The inferred schema as a dict |
draft_contract(data, output=...) |
A starting contract: every column with its type, all required. Returns a dict; output also writes it as .triplex.yaml |
validate(data, contract) |
Checks data against a contract (a .triplex.yaml path or a dict); returns {"valid": ..., "errors": [...]} |
convert(input, output) |
Converts a file between .csv, .tsv, .jsonl and .parquet, by extension |
anonymize(data, recipe, mapping_out=...) |
Masks the columns a .triplex.yaml recipe declares |
synthesize(data, rows=..., seed=..., method=...) |
Generates a synthetic table; method is "copula" (default), "bayes-net" or "marginals" |
A contract is what you expect the data to be; an inferred schema is what one table holds right
now. draft_contract gives you a first contract to edit (add null-rate, range, mean or pattern
limits) and commit. Passing the dict from infer_schema to validate is an error.
data is a file path, a pandas or Polars DataFrame, a pyarrow Table, or anything else Arrow can
read. anonymize and synthesize read .csv and .parquet paths; infer_schema and
validate also read .tsv and .jsonl.
anonymize and synthesize return a result with two fields: report (a dict) and table.
Read the table with table.to_pandas(), table.to_polars() or table.to_arrow(), or pass
output="result.csv" to have it written as CSV as well.
An engine error is raised as triplex.TriplexError, with a stable code such as
"COLUMN_NOT_FOUND".
pandas, Polars and pyarrow are optional: install the ones you use. pandas input and
to_pandas() need pyarrow; Polars works without it.
Anonymizing
import os
os.environ["CUSTOMER_SALT"] = "..." # better: set it outside the script
run = triplex.anonymize(df, "recipe.triplex.yaml", mapping_out="mapping.csv")
masked = run.table.to_pandas()
- The salt is read from the environment variable each recipe column names (
salt_env). It is never a function argument. - The mapping file reverses the pseudonyms. It is written to the path you give in
mapping_outand is not returned to Python. Passmapping_passphrase_env="SOME_VAR"to have it encrypted with the passphrase in that variable. - The result is pseudonymized, not anonymous, as long as the mapping file exists. The report says
so in
report["warning"].
Synthetic data
None of the three methods here carries a formal privacy guarantee. Every report includes a
privacy_statement and measured leakage figures; read them before sharing the output.
Identifier-like columns and dates are left out of the synthetic table and listed in
report["columns_dropped"].
The differentially private methods and the sketch method of the command line are not available from Python yet.
Where your data goes
Nowhere. The engine runs inside your Python process and makes no network call. Files are read from and written to the paths you pass.
Limits
- Column types of a result table are inferred by the engine from the values (integer, float, boolean or text). They are not copied from the input, so a date column comes back as text.
- A table is copied when it is handed to the engine and again when it comes back. Large tables are untested.
- Tested on Linux with CPython 3.13, pandas, Polars and pyarrow.
Metadata
Release files for triplexanalytics 0.2.2
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 | |
|---|---|---|---|---|
| triplexanalytics-0.2.2.tar.gz | 203.0 kB | With provenance | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| triplexanalytics-0.2.2-cp39-abi3-win_amd64.whl | CPython 3.9 | abi3 | Windows x86-64 | Details |
| triplexanalytics-0.2.2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.9 | abi3 | Linux glibc 2.17+ x86-64 | Details |
| triplexanalytics-0.2.2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | CPython 3.9 | abi3 | Linux glibc 2.17+ ARM64 | Details |
| triplexanalytics-0.2.2-cp39-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl | CPython 3.9 | abi3 | macOS 11.0+ ARM64, macOS 10.12+ universal2 (ARM64, x86-64), macOS 10.12+ x86-64 | Details |
Total release size: 19.8 MB
Release files / triplexanalytics-0.2.2.tar.gz
| Download URL | triplexanalytics-0.2.2.tar.gz |
|---|---|
| Size | 203.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7fcee1dcd93872ecd1290865413b8c91bd7591fbd7aa6922cf3f020070ee3947
|
|
BLAKE2b-256 checksum How to use checksums |
0da1543cd165109ea69b01f1f94d6115bbcc42cf5f9d8f4201a8838a7b00ffca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.
Transparency logRelease files / triplexanalytics-0.2.2-cp39-abi3-win_amd64.whl
| Download URL | triplexanalytics-0.2.2-cp39-abi3-win_amd64.whl |
|---|---|
| Size | 3.5 MB |
| Tags | CPython 3.9 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
cc300f9a32d994b5d4070744d8783c370d7d497bfa80576519b46010f86003ac
|
|
BLAKE2b-256 checksum How to use checksums |
7091c9850b512c94a9a1454546328a1736d7a111ce0874aeeedcc2e29a5f4759
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.
Transparency logRelease files / triplexanalytics-0.2.2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | triplexanalytics-0.2.2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 4.4 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
6a757b0e2ad720ee76624a26e828650dcca2aaa1b4d17b3be43c9f8eb4bdfca5
|
|
BLAKE2b-256 checksum How to use checksums |
f27024374545d4e865dab17bd98054c94e11d0826eff4777e9544aad0269c925
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.
Transparency logRelease files / triplexanalytics-0.2.2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | triplexanalytics-0.2.2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 4.2 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
a181460697de6108e858608f32996efaaba8f889de24adb6d7f755ee221a4e90
|
|
BLAKE2b-256 checksum How to use checksums |
4f1b47dcfd2eb58de9f63b7d8143575e0733d5c587b0631230b21c1faf7232f5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.
Transparency logRelease files / triplexanalytics-0.2.2-cp39-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
| Download URL | triplexanalytics-0.2.2-cp39-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl |
|---|---|
| Size | 7.5 MB |
| Tags | CPython 3.9 abi3 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
393d1961d7c4854404efca015e30d3065b994c9b4b9898a97db7d0620f6c2713
|
|
BLAKE2b-256 checksum How to use checksums |
92997473d28ca420b7dcf0c3d661ad61d7d96a2930f15e3934486f902264f70a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.
Transparency logSecurity for triplexanalytics 0.2.2
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.
Full provenance
All 5 files in this release have been uploaded with provenance metadata.
Attestation for triplexanalytics-0.2.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.
Transparency logA 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.