Skip to main content

⚗️ Zeolite


Zeolite is a Python library that uses a simple configuration approach to define a table/schema structure. Raw data can normalised, cleaned, and validated against the schema in a performant and standardised way.

The schema implements a multi-stage pipeline:

  • normalise - Normalises the dataset to ensure column headers align with the defined schema/column definitions
  • coerce - Coerces the data types of the columns in the dataset to match the defined schema/column definitions
  • prepare - Appends new columns to the dataset representing cleaned & derived/calculated columns and check/validation columns based on the validation rules
  • validate - Applies validation rules/thresholds to the dataset, captures errors and determines if the dataset as a whole should be rejected
  • filter - Drops rows that have failed checks based on the remove_row_on_fail argument
  • refine - Renames working columns, and drops unneeded column to refine the dataset to the final structure

The final datasets are guaranteed to be in the correct format and can be easily exported to a variety of formats. In addition, Zeolite captures errors and warnings during the processing of the data, which can be used to improve the quality of the data.

Example

First we define a data schema that describes how our data should be, and includes both structural definitions, cleaning functions, and validation/data quality checks

import zeolite as z

data_schema = z.schema("individual").columns(
    z.col.str("id")
    .clean(z.Clean.id(prefix="ORG_X"))
    .validations(
        z.Check.not_empty(
            warning="any", 
            error=0.1, 
            treat_empty_strings_as_null=True, 
            remove_row_on_fail=True
        ),
        z.Check.unique(check_on_cleaned=True, reject="any"),
    ),

    z.col.str("birthdate")
    .clean(z.Clean.date())
    .validations(z.Check.not_null(check_on_cleaned=True, reject="all")),

    z.col.str("gender").clean(
        z.Clean.enum(
            match="ignore_case",
            enum_map={
                "m": "Male", "male": "Male",
                "f": "Female", "female": "Female",
                "d": "Gender Diverse", "diverse": "Gender Diverse"
            },
        )
    ),

    z.col.str("is_active").clean(
        z.Clean.boolean(
            true_values={"yes", "active"}, false_values={"no", "inactive"}
        )
    ),

    z.col.str("ethnicity").clean(z.Clean.sanitised_string()),
    z.col.str("ethnicity_2").clean(z.Clean.sanitised_string()),
    z.col.derived(
        "is_maori",
        function=(
                z.ref("ethnicity").clean().col.eq("maori")
                | z.ref("ethnicity_2").clean().col.eq("maori")
        ),
        data_type="boolean",
    ),
)

Once we have the schema defined, we can apply it against our Polars DataFrame/LazyFrame

import polars as pl

df = pl.DataFrame({
    # the third row will be removed because the empty string is treated as null 
    # and our `Check.not_empty` has `remove_row_on_fail=True`
    "id":["1","2","","4"],
   
    # we can handle multiple date formats (including weird Excel dates!)
    "birthdate":["1970-01-01","33746","","1987-01-25T00:00:00Z"],
    
    # using our enum_map, we can collapse category variants to a common definition
    "gender":["Male"," Male "," F ","d"],
    
    # boolean fields can be coerced from categories/values as well as bools
    "is_active":["active","inactive",None,"true"],
    
    # sanitising these fields means that we can match e.g. 'maori' more accurately
    "ethnicity":["Maori","Pakeha",None,"Asian"],
    "ethnicity_2":[None,"Māori ",None,"maori"],
})

res = data_schema.apply(df)

The .apply(...) method returns a ProcessingResult carrying either a ProcessingSuccess or a ProcessingFailure. Check the success attribute to tell them apart:

if success := res.success:
    # Do stuff with the data (LazyFrame) on success
    clean_df = success.data.collect()
elif failure := res.failure:
    # Gracefully handle failures
    failed_stage = failure.failed_stage

# Regardless of the result, we have access to all the errors 
# that occurred during processing, which we can use for 
# logging/data quality reports  
errors = res.errors
for e in errors:
    print(e.message)

# Row counts are available on the result itself
if res.counts is not None:
    print(res.counts.total_rows, res.counts.failed_rows)

# We can also examine the snapshot data at each stage if necessary
# This is particularly useful to capture & debug working data!
# On a success every stage is present; on a failure the stages that
# were not reached are None.
if success := res.success:
    prepared_df = success.prepared.collect()
    validated_df = success.validated.collect()

Chaining cleans

A column takes one clean. z.Clean.chain(...) runs several cleans in order as one, each step receiving the previous step's output. See the cleans guide.

z.col.str("smoker").clean(
    z.Clean.chain(
        z.Clean.enum(enum_map={"Unknown": "99", "Yes": "1", "No": "2"}),
        z.Clean.int(),
    ).alias("smoker_code")
)

Running stages individually

.apply(...) runs every stage in a fixed order. For finer control, pipeline(schema) exposes each stage on its own so you can skip the ones your data does not need, or break out mid-pipeline to do work Zeolite cannot express. See the pipeline guide.

from zeolite.pipeline import pipeline

pipe = pipeline(data_schema)

normalised = pipe.normalise(df)
coerced = pipe.coerce(normalised.data)
prepared = pipe.prepare(coerced.data)

Synthetic test data

Use zeolite.synthetic.recipe(schema) to generate canonical schema inputs with seeded Polars helpers and explicit overrides. See the test data guide for dependent dates, weighted sampling, exact allocations, and typed Python callbacks.

Schema extensions

Named clean, check, and derive extensions can be stored in JSON specs without embedding their Polars expressions. See the extension guides for writing extensions, loading specs, and config serialization.

Metadata

Release files for zeolite 0.7.1

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

Source distribution (sdist)

Source distribution for zeolite 0.7.1
File Size Uploaded Provenance Actions
zeolite-0.7.1.tar.gz 196.0 kB With provenance Details for zeolite-0.7.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for zeolite 0.7.1
File Interpreter ABI Platform Actions
zeolite-0.7.1-py3-none-any.whl Python 3 none any Details for zeolite-0.7.1-py3-none-any.whl

Total release size: 327.0 kB

Release files / zeolite-0.7.1.tar.gz

Download URL zeolite-0.7.1.tar.gz
Size 196.0 kB
Tags Source
SHA-256 checksum
How to use checksums
49a50e47ed24fdc6ae055520a1c4677f3063f97bff9d84f6a200a4881951612b
BLAKE2b-256 checksum
How to use checksums
d170a31bb25d2eee954b27232331fbafa647f0a6cf73031c01510faf83956ed4
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 Nov 10, 2026.

Transparency log

Release files / zeolite-0.7.1-py3-none-any.whl

Download URL zeolite-0.7.1-py3-none-any.whl
Size 131.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7d5b982514efb04887ab1003dd324e33c86ac9f80839ba90b90e972a3ebcc850
BLAKE2b-256 checksum
How to use checksums
b437fb36160cc059fc7cdb76660a3d74a87a0ca41770c9d32eccac30f22c3efc
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 Nov 10, 2026.

Transparency log

Security for zeolite 0.7.1

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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for zeolite-0.7.1.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 Nov 10, 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.

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