Skip to main content

Strongly-typed DataFrames for Python, powered by Rust.

Project description

Pydantable

Typed dataframe transformations for FastAPI + Pydantic services, powered by a Rust execution core.

Pydantable keeps your Pydantic schemas as the source of truth for:

  • column types + nullability (Optional[T])
  • expression validity (type errors fail early during AST building)
  • derived schema migration through chained transforms

Execution is dispatched through a backend boundary (default: Polars-style contract), with optional interface modules for pandas and pyspark.

What You Get

Typed, schema-safe transforms:

  • DataFrameModel.with_columns(...)
  • DataFrameModel.select(...)
  • DataFrameModel.filter(...)
  • DataFrameModel.join(...)
  • DataFrameModel.group_by(...).agg(...)
  • DataFrameModel.collect() for materialization into Python column data
  • DataFrameModel.rows() and DataFrameModel.to_dicts() for row-wise materialization

Backend Boundary (Polars-style by default)

Pydantable’s default exported interface emulates a Polars-style dataframe contract:

  • join collision handling via suffix for right-side non-key columns
  • SQL-like null propagation rules for arithmetic/comparisons/filter
  • ordering is not a stable API guarantee (tests compare deterministically on keys)

Select an interface module (import-based)

from pydantable.pandas import DataFrameModel as PandasDataFrameModel
from pydantable.pyspark import DataFrameModel as PySparkDataFrameModel
from pydantable import DataFrameModel as DefaultDataFrameModel

Select the backend at import time (env-var based)

import os
os.environ["PYDANTABLE_BACKEND"] = "polars"  # or "pandas" / "pyspark"

Then:

from pydantable import DataFrameModel

Current status

pydantable.pandas / pydantable.pyspark currently keep the typed API boundary in place, but execution still falls back to the existing Rust/Polars engine. This lets you validate contract equivalence while incrementally replacing the executors later.

See:

  • docs/BACKENDS.md
  • docs/INTERFACE_CONTRACT.md

Quick Start

from pydantable import DataFrameModel

class User(DataFrameModel):
    id: int
    age: int | None

df = User({"id": [1, 2], "age": [20, None]})

df2 = df.with_columns(age2=df.age * 2)
df3 = df2.select("id", "age2")
df4 = df3.filter(df3.age2 > 10)

result = df4.collect()
print(result)  # {"id": [1], "age2": [40]}

Semantics Contract (high level)

Null semantics are SQL-like (propagate_nulls):

  • arithmetic: NULL + anything yields NULL
  • comparisons: if either side is NULL, the comparison result is NULL
  • filter(condition): keeps rows where the condition evaluates to exactly True

Collision + ordering are explicit:

  • with_columns(...) uses collision replacement semantics for deterministic schema evolution
  • join(..., suffix=...) renames right-side non-key overlaps with the suffix
  • collect() row order is not guaranteed; compare by key columns when needed

For the full contract details:

  • docs/INTERFACE_CONTRACT.md

Installation

Pydantable requires Python 3.10+.

From this repo:

pip install .

pip install . builds the Rust extension via maturin when toolchains are available. The current skeleton requires the Rust extension for expression typing and collect().

Development & CI

  • Lint: ruff check .
  • Tests: pytest -q
  • CI runs the same test suite across backend selections via PYDANTABLE_BACKEND.

Docs

  • docs/DATAFRAMEMODEL.md for the DataFrameModel contract/design spec
  • docs/FASTAPI.md for end-to-end FastAPI integration examples
  • docs/WHY_NOT_POLARS.md for positioning + trade-offs
  • docs/DEVELOPER.md for local setup and contribution workflow
  • docs/ROADMAP.md for project phases

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydantable-0.4.0.tar.gz (51.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pydantable-0.4.0-cp313-cp313-win_arm64.whl (16.7 MB view details)

Uploaded CPython 3.13Windows ARM64

pydantable-0.4.0-cp313-cp313-macosx_11_0_arm64.whl (15.0 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pydantable-0.4.0-cp313-cp313-macosx_10_12_x86_64.whl (16.0 MB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

pydantable-0.4.0-cp312-cp312-win_amd64.whl (18.3 MB view details)

Uploaded CPython 3.12Windows x86-64

pydantable-0.4.0-cp312-cp312-musllinux_1_2_x86_64.whl (16.6 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

pydantable-0.4.0-cp312-cp312-musllinux_1_2_aarch64.whl (15.6 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ ARM64

pydantable-0.4.0-cp312-cp312-manylinux_2_28_aarch64.whl (15.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

pydantable-0.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (16.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

pydantable-0.4.0-cp312-cp312-macosx_11_0_arm64.whl (15.0 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pydantable-0.4.0-cp312-cp312-macosx_10_12_x86_64.whl (16.0 MB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

pydantable-0.4.0-cp311-cp311-macosx_11_0_arm64.whl (15.0 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pydantable-0.4.0-cp311-cp311-macosx_10_12_x86_64.whl (16.0 MB view details)

Uploaded CPython 3.11macOS 10.12+ x86-64

File details

Details for the file pydantable-0.4.0.tar.gz.

File metadata

  • Download URL: pydantable-0.4.0.tar.gz
  • Upload date:
  • Size: 51.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.12.6

File hashes

Hashes for pydantable-0.4.0.tar.gz
Algorithm Hash digest
SHA256 78f9ee8871740cb6316935999aecb4a5872b526cc626e7b89a97994159a9f7c9
MD5 4b791645d5a8466b31367471ad45399d
BLAKE2b-256 84ec50409dcc2d1a87830c7f55017b860f32df7ae3fe263d278225c102f2fff1

See more details on using hashes here.

File details

Details for the file pydantable-0.4.0-cp313-cp313-win_arm64.whl.

File metadata

File hashes

Hashes for pydantable-0.4.0-cp313-cp313-win_arm64.whl
Algorithm Hash digest
SHA256 295617976ae10b1b0b3367d2ed84036a2f1094a625660761e372627acc90d24e
MD5 3020554f8c940182fc15f641589ff83f
BLAKE2b-256 65b35123006d4ee0c3a03f8437e1e654cf1cdd48843920201be677d5efa84a47

See more details on using hashes here.

File details

Details for the file pydantable-0.4.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pydantable-0.4.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 915deb8a5666d990a48766a72c56bda0a2f23e5b2180cd1eb1b5709c21fe7631
MD5 4eb50338a1c0aa2cd9e1f699f62a1f6d
BLAKE2b-256 b2405f1941b649baa37fb940220bb202458753c12e8f2aba7bc1c355e6437638

See more details on using hashes here.

File details

Details for the file pydantable-0.4.0-cp313-cp313-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pydantable-0.4.0-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 7814511d319f4fddc083a0a495a0b7cc5fe3b0ad7b7a0fb501edc411497dd2fc
MD5 a533737b5fb2ac56cb505f2514e73584
BLAKE2b-256 1c64cf7d1b33d664cc0611c0510de80dff4fc9821e6be629a8df1b78bcf7f124

See more details on using hashes here.

File details

Details for the file pydantable-0.4.0-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for pydantable-0.4.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 9d7a623b52a726ccd0fe61c6164a72a61fa34406c05543a098077e1173cd474b
MD5 320372c4a1ac83b7a7fae3bc8735e13c
BLAKE2b-256 3e7613b2f5ce817400720b3c9f463ad776392169d46c5252b73349c719cc593c

See more details on using hashes here.

File details

Details for the file pydantable-0.4.0-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pydantable-0.4.0-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 98038ce97c1a56a78b14c68404427c5e0d36a9218c31286ef30d015012858275
MD5 3d1a8196b2f9c9d49d7e20860207afb6
BLAKE2b-256 b853e6259a3a682f1ed150a13b078191a3962c0e17e0abb3f668041edfdb6fb4

See more details on using hashes here.

File details

Details for the file pydantable-0.4.0-cp312-cp312-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for pydantable-0.4.0-cp312-cp312-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 4adec3130d8b8ff94dd9631e36849ff06d17176358d04da6d0d26cba40d03d41
MD5 204b3682a266ecf9e4900d97af89f288
BLAKE2b-256 30fe88ad59576f9fd964234e9fb0a321f482e2e35fd8e85330b1849c66ac45d1

See more details on using hashes here.

File details

Details for the file pydantable-0.4.0-cp312-cp312-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pydantable-0.4.0-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 f60bf44c11182fd779ee17faf9973862bdc6fd7e41ae884c28d3a6326fcc56b5
MD5 63b0d831a17547981eaa6b40abf3c9cc
BLAKE2b-256 84ba81bb62cb66c3c71f9e84c6d4772ec95c7389ea51f2bad5104f1e916501af

See more details on using hashes here.

File details

Details for the file pydantable-0.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pydantable-0.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 781f9c5114717957bb3df9b940397e2623b16714805c775694ebe3de226b9b1a
MD5 16f11dc15c69b1bb54a665a424fdfeec
BLAKE2b-256 c0a21c36df72a8f690c7b9e8e7ba09e1f3ec64ee08cddbab5bc7aed927279918

See more details on using hashes here.

File details

Details for the file pydantable-0.4.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pydantable-0.4.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 347e064c6a72632423feffd284c69a80b941fc7d5e0a40ef3f6d5cbcdba17add
MD5 630ced301ea188966cb4ce8358170f16
BLAKE2b-256 cf4ca311eadcb52c5727963b412757031cf3b13087ced9d7cc66ec6c7bade030

See more details on using hashes here.

File details

Details for the file pydantable-0.4.0-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pydantable-0.4.0-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 8443a680c612b4cd254db50d62c510bac7f3b4d8f5d3af1e4c54e4e7f90518aa
MD5 09563b021b3e47bc751ce44fc3806f8d
BLAKE2b-256 6fffc6f28977c3aac08ca20abbe206765ad2db178e488e32536aaeeb0198008e

See more details on using hashes here.

File details

Details for the file pydantable-0.4.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pydantable-0.4.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6b7237cca71d1e666e267baa33a64d1a29176633eddf25fa50dc472caebbd920
MD5 c141e058b2feb4fbc7a0a289402055a7
BLAKE2b-256 ccb58759a12a3168c871dbe5bab73f505c604f65cf9df54b8e56dd78773ec32d

See more details on using hashes here.

File details

Details for the file pydantable-0.4.0-cp311-cp311-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pydantable-0.4.0-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 0de5e00f74df40d8fc7c5f684be23b6d49952eb2ad7ccf14c517bb1e41485e65
MD5 582ea2d13b7a717e07bfb3695a584fed
BLAKE2b-256 c22f905182bb9a51445ffd377f7b1c7a947ae1e3b7c2e59c257f839b5171a2ca

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page