Skip to main content

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.

pip install triplexanalytics

The distribution is called triplexanalytics; the import is import triplex. Wheels cover Linux (x86_64 and aarch64), macOS and Windows, for Python 3.9 and later.

To build from a source checkout instead (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_out and is not returned to Python. Pass mapping_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.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for triplexanalytics 0.4.0
File Size Uploaded Provenance
triplexanalytics-0.4.0.tar.gz 212.9 kB With provenance Details

Built distributions (wheels)

Table of built distributions (wheels) for triplexanalytics 0.4.0
File
triplexanalytics-0.4.0-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details
triplexanalytics-0.4.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 abi3 Linux glibc 2.17+ x86-64 Details
triplexanalytics-0.4.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.9 abi3 Linux glibc 2.17+ ARM64 Details
triplexanalytics-0.4.0-cp39-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl CPython 3.9 abi3 macOS 10.12+ universal2 (ARM64, x86-64), macOS 11.0+ ARM64, macOS 10.12+ x86-64 Details

Total release size: 20.0 MB

Release files / triplexanalytics-0.4.0.tar.gz

Download URL triplexanalytics-0.4.0.tar.gz
Size 212.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a7ac97de12c3df5f1392be8f424f81bd66a2d9baa1923d81aaded078e10aea12
BLAKE2b-256 checksum
How to use checksums
551af7ef5f3cfde7093a7548b450bbe109422d1a44f7706f025899aec8e15a9e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 23, 2026.

Transparency log

Release files / triplexanalytics-0.4.0-cp39-abi3-win_amd64.whl

Download URL triplexanalytics-0.4.0-cp39-abi3-win_amd64.whl
Size 3.6 MB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
7a23b2cd50879e4169ff1593867dfe5661f10c4683a91f86d689ad38dbcd0be0
BLAKE2b-256 checksum
How to use checksums
fa380ef29c2af80c4bdf369755d35e49f6e50b24469223690c711e19761e36ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 23, 2026.

Transparency log

Release files / triplexanalytics-0.4.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL triplexanalytics-0.4.0-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
7c72bee27d7feba50db777370a6a2a49c256ff94f645502403b1fa9440369012
BLAKE2b-256 checksum
How to use checksums
297e539aa61aa8c9840f1a504bc444213fd013e4727f43b4b62e23d97cc8dab5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 23, 2026.

Transparency log

Release files / triplexanalytics-0.4.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL triplexanalytics-0.4.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 4.3 MB
Tags CPython 3.9 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
2c2bdbbcc78c0594c40b801d4f2f802c3fd70622c0488fc0650a477a08f15f2c
BLAKE2b-256 checksum
How to use checksums
fbb405ff952a128202c7947a46e6bbe3dbfd241b8f79fc482ba40267920c8171
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 23, 2026.

Transparency log

Release files / triplexanalytics-0.4.0-cp39-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl

Download URL triplexanalytics-0.4.0-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
158724d22940a5be0d84ee80fe52f5b1edc7fd2b840974f85d2d5703374315f5
BLAKE2b-256 checksum
How to use checksums
c6c52773b376efbaf0269d6698ffe2e5c2af1a504b1836d07101e24065150ce9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 23, 2026.

Transparency log

Security for triplexanalytics 0.4.0

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.

Select from 5 files

Attestation for triplexanalytics-0.4.0.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 23, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

0.4.0 This release

5 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page