Skip to main content

Strongly-typed DataFrames for Python, powered by Rust.

Project description

PydanTable

CI Documentation PyPI version Python versions License: MIT

Typed dataframe transformations for FastAPI and Pydantic services, backed by a Rust execution core.

Current release: 0.9.0 · Python 3.10+


Documentation

The full manual lives on Read the Docs:

https://pydantable.readthedocs.io/en/latest/

That site is the supported entry point for concepts, contracts, API notes, and examples. The sections below point to the same pages so you can jump straight from GitHub.

Topic Read the Docs
Home / overview Documentation home
DataFrameModel contract (inputs, transforms, collisions, materialization) DataFrameModel (SQLModel-like)
Column types (scalars, structs, list[T], nullability, unsupported cases) Supported data types
FastAPI (routers, bodies, collect, responses) FastAPI integration
Execution model (collect, to_dict, to_polars, optional Python Polars, UI modules) Execution (Rust engine)
Semantics (nulls, joins, ordering, reshaping, windows — Polars-style contract) Interface contract
Roadmap (0.5.0–0.9.0 shipped, path to v1.0.0) Roadmap
Why not use Polars directly? Why not just use Polars?
Pandas-style imports (pydantable.pandas) Pandas UI
PySpark-style imports (pydantable.pyspark) PySpark UI
PySpark helpers & parity PySpark interface · PySpark API parity
Polars parity (scorecard, workflows, transformation roadmap) Parity scorecard · Polars-style workflows · Transformation parity roadmap
Contributors (build, test, benchmarks, releases) Developer guide
Plan / vision (architecture phasing) Plan document
Python API reference (autodoc) API reference

For copy-paste convenience, the site base URL is:

https://pydantable.readthedocs.io/en/latest/


What PydanTable does

PydanTable keeps Pydantic models as the source of truth for:

  • column types and nullability (Optional[T] / T | None)
  • typed expressions — invalid combinations fail when the expression is built (Rust AST), not only at runtime
  • schema evolution — chained transforms produce new model types with stable rules (e.g. with_columns name collisions)

The default API feels Polars-like; optional pydantable.pandas and pydantable.pyspark modules only change naming and imports — execution is always the native core. Details: Execution, Interface contract.

Expression surface (current release, Rust-typed Expr):

  • Globals in select: global_sum, global_mean, global_count, global_min, global_max, and global_row_count() (row count / COUNT(*)). PySpark: F.count() with no argument for row count; F.count(F.col(...)) for non-null column count.
  • Windows: row_number, rank, dense_rank, window_sum, window_mean, window_min, window_max, lag, lead with Window.partitionBy(...).orderBy(...) / .spec(), plus framed windows (rowsBetween, rangeBetween) for supported operations.
  • Temporal: strptime, unix_timestamp, cast from strdate / datetime (Polars parsing; use strptime for fixed formats), dt_* parts, dt_nanosecond on datetime / time.
  • Maps / binary: map_len, map_get, map_contains_key, binary_len, including nested JSON-like map value dtypes with string keys.

PySpark-named helpers live under pydantable.pyspark.sql.functions. Details: Supported types, Interface contract, CHANGELOG.


Install

pip install pydantable

Optional Python Polars (for to_polars() only):

pip install 'pydantable[polars]'

From a git checkout, the Rust extension must be built (e.g. with maturin):

pip install .

See Developer guide — local setup for maturin develop, release builds, and CI parity.


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)

print(df4.to_dict())

Example output:

{'age2': [40], 'id': [1]}
  • Materialization: collect() returns a list of Pydantic row models; to_dict() returns columnar dict[str, list].

  • Alternate UIs:

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

More examples: FastAPI integration, Polars-style workflows.

Input quality policy (optional): constructors are strict by default, and can be switched to best-effort ingestion with ignore_errors=True plus on_validation_errors=... to receive failed rows (row_index, row, validation errors). See DataFrameModel docs.


Development

make check-full   # Ruff, mypy, Rust fmt/clippy/tests (see Makefile for `rust-test` env)
pytest -q         # or: pytest -n auto  with the [dev] extra

Rust + Python: see Developer guide (formatting, maturin, make rust-test for cargo test with the venv PYTHONPATH, benchmarks, contribution workflow).


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.9.0.tar.gz (127.9 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.9.0-cp313-cp313-win_arm64.whl (16.7 MB view details)

Uploaded CPython 3.13Windows ARM64

pydantable-0.9.0-cp313-cp313-macosx_11_0_arm64.whl (14.9 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pydantable-0.9.0-cp313-cp313-macosx_10_12_x86_64.whl (16.5 MB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

pydantable-0.9.0-cp312-cp312-win_amd64.whl (18.4 MB view details)

Uploaded CPython 3.12Windows x86-64

pydantable-0.9.0-cp312-cp312-musllinux_1_2_x86_64.whl (16.8 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

pydantable-0.9.0-cp312-cp312-musllinux_1_2_aarch64.whl (15.3 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ ARM64

pydantable-0.9.0-cp312-cp312-manylinux_2_28_aarch64.whl (15.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

pydantable-0.9.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (16.9 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

pydantable-0.9.0-cp312-cp312-macosx_11_0_arm64.whl (14.9 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pydantable-0.9.0-cp312-cp312-macosx_10_12_x86_64.whl (16.5 MB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

pydantable-0.9.0-cp311-cp311-macosx_11_0_arm64.whl (14.9 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pydantable-0.9.0-cp311-cp311-macosx_10_12_x86_64.whl (16.5 MB view details)

Uploaded CPython 3.11macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for pydantable-0.9.0.tar.gz
Algorithm Hash digest
SHA256 021562125c704f9016807060ad8a26b8770bdfdf18c6cfc26836e61df13e5e74
MD5 037e9254b33a2416293986d0bd7775a5
BLAKE2b-256 f62fa200114adb98db4733e7646dceaae9cb15a7f906c32d41621b1b6c9a60be

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-0.9.0-cp313-cp313-win_arm64.whl
Algorithm Hash digest
SHA256 2b35518344f20b8d75adedad7b2f0ab77c4b63296c20448a4c5ccfb338379fbc
MD5 0db7614833932492ba2f8a35471982b1
BLAKE2b-256 f45451a99d75d72a0d21f26b15932659bb5fa7180067aa9d18f5ea4d5f2b34e9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-0.9.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f08c83a22d6e6c07079745a8e2e3b318b4de35b04158cfb3cd4ce5494519d6a1
MD5 fd9533a5d5646049cd996b777119cd45
BLAKE2b-256 c45814c436d906506d19ddf54b913063aa85b608f007335bcedb9f3353f759f5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-0.9.0-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 351a142a9d556c345eb0a642a8f0040e44357a3e1429fb4bb77d22b1528a22f4
MD5 17050431bb132baf44682fdcc6a28abd
BLAKE2b-256 e18a170c2eed370c1256c954faa473202a3daff2fa62cb86144301886adb5805

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-0.9.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 ea5919968d1ce46d9a86d59aaba7da078e7e36edda831070277dca8269c093a0
MD5 4539b68855bb8656044430d7a608a4d3
BLAKE2b-256 9d15a3e3a009d468cc1fb8ae9415833764518c4d1ce3fa832fb7be79437a5844

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-0.9.0-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 cf1204e14881d5e755264613dc35279951559d046a991b6adb5f3ce7c710f41d
MD5 48db80e1c99159089fe1fdc6084a1bd6
BLAKE2b-256 a70223e4931395a68b086ea46be25abc8d98a070c4c87f06241687c64fd22b4e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-0.9.0-cp312-cp312-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 974a5865eb7adc70604360dde6d54937213a1e44012ca6d1e48b462c063b573b
MD5 8a253289ebbb1151b36740874d628012
BLAKE2b-256 7837d2f84ef5eefbcac2cb800a45755a80f27daf6f9b2d559a2f8cf470b50e1a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-0.9.0-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 ef812bb2d429db4960c81edfcc2b868db2db37bb432f8f9c1ac461097dcce2a0
MD5 e5d6ce220f74c00b821e0e2c8e098520
BLAKE2b-256 476714cbad70a872469ba244abaa9d60007893de667937e3429ec8821b79b2f6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-0.9.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4e4d5305ad852510030dbca135bec86e4151af026255fedf447d7d523fa7457b
MD5 284a88fb1e29b361d1187b90f2637e98
BLAKE2b-256 bc15d3df6d3dd3208e9f0b1f77e5dbee322f3b5cf38f093ad612c3eb8c221261

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-0.9.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8013ac3a59cb08967e95aec9b113f4a811d4506033782db0cbd342f4201f91b3
MD5 e83057ff6ce441d9dc5923895fe88fb3
BLAKE2b-256 0f8e178590d89260f182f74dc3620f817a06316f8a02cd29f542caec3f0ce09d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-0.9.0-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 6c7612de404ca368888d95c08b30499a1ddf613d1c5a3eb65e86f4c834883869
MD5 a5ff18506d0beb08b581b59ed676dca9
BLAKE2b-256 376803510299c09bdac2e9aebceba62f69e00a53af657bc9cc9a3663603a5925

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-0.9.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 671ee0f0623b75ae6175dcc22e9f813228827792efb7fcea86c345aaf482fcec
MD5 5a7b1f37ed709d386749526da0981045
BLAKE2b-256 119c47f4bf1c103cea61f4e53b748c8cf1e788d8803d9638b16f18c2c9ced3f8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-0.9.0-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 42547bc3fddce122e60e2bfb98b26808626596844af2c3328d07a78e44ccdc18
MD5 688d380124beb7114a25f735f810e783
BLAKE2b-256 0ab82c07c30952ff6eb8fc17dacc71b75b17c27fd4c26bfb1423a6edd0389c3d

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