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.12.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.12.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.
  • Map utilities: map_keys(), map_values(), map_entries(), and map_from_entries() for per-row key/value extraction and reconstruction on dict[str, T] columns.

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

Uploaded CPython 3.13Windows ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.12+ x86-64

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

Uploaded CPython 3.12Windows x86-64

pydantable-0.12.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.12.0-cp312-cp312-musllinux_1_2_aarch64.whl (15.3 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ ARM64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

pydantable-0.12.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.12.0-cp312-cp312-macosx_11_0_arm64.whl (14.9 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.12+ x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

pydantable-0.12.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.12.0.tar.gz.

File metadata

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

File hashes

Hashes for pydantable-0.12.0.tar.gz
Algorithm Hash digest
SHA256 0933550f35815af486edafb976eed1b865d4e7e8927bfe149fe8a08068c84b9d
MD5 0e74d0eb83c0d88962a594e90dfb35db
BLAKE2b-256 6e3c058f1a2e4f1859ccdcde628e05889b09ecbdf1d1d35a25c0a72858d61b8f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-0.12.0-cp313-cp313-win_arm64.whl
Algorithm Hash digest
SHA256 3bf72353945a367c6c959bcfc12e375eb32dee1c35fb15d3e33c848d5784e50b
MD5 f7534156102539ac26cda9cdce3e4b02
BLAKE2b-256 53772a555127bb1430064f837adf20c769b62c135b111d0ff5aba8f029ad2bd4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-0.12.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9021d70c8169c935050fb39b54f10229d823fab845d2f701055a1d651e5ceb4d
MD5 a48ee3bc7121b009401e4909eaf5a5a1
BLAKE2b-256 84d1f0cc5fe6464eada7325c15b951c7f7cfe95d392f7cb14ca7c2d01d484fae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-0.12.0-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 f9472f5a3649cbca6abff1b593edde289cda4806105714f273703c250d53aa93
MD5 a1983e2474807ba9023d009351b5b3ed
BLAKE2b-256 cee426ef237d18cfde03f4f02bf592568bf4856a5aafbf4be598204e95781a18

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-0.12.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 f7830460d8e3bb4bc7aea20227148850663c2e8ee714e0d68d9700abfaded422
MD5 c2fb598871b590d0daab830c122f3ebd
BLAKE2b-256 376b9f61dd673c9003d46dc96d165408616dc9c333e0041daa349b7d9def90f4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-0.12.0-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 c466ed3abda03941fefdd77ca7da48686b60ccc8f692029f06d50e2cc5516884
MD5 96cc3950969b1c79c4b6f242d5750cf8
BLAKE2b-256 fdb77e7ab084d10de937a1b77652535efefe8b42971545401c4ca9dc30ff3713

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-0.12.0-cp312-cp312-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 d6593d346873cfc3b8b602051bf5812eefabbb9065b8e3cb1faa683b7ef0f874
MD5 27118321b698a82ecc855897704bd3d6
BLAKE2b-256 d196c7e26d84b6f194fd8051219c31313e5d63256d27030d4968529094b1471b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-0.12.0-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 eff80e5749179092a9e69f37097c54d0e7bef96a7dd2648c39d374ce37dcda22
MD5 19493551e6ec91afe91bea45eedfb139
BLAKE2b-256 bd41c5d6d83140f83fd99755f411ebac2d2c4e95cc244cedc1759ba5b0a607dc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-0.12.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5fde025381b4baf223abb976cbb85770ad0ff0415a5616d8d0a4035be37bcddf
MD5 6105877dff1a6a1d73e1819dceefa5a1
BLAKE2b-256 34b650171a174d77b8e90ca405373fb26a8bf368d52a527444e02b7e9d397bda

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-0.12.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7810c80fc5faa97ecdd98de77c4e8ab744c75e2aad02c91601d40fe0cb750f87
MD5 f72e7a41680ac52de29025c23f4fd05c
BLAKE2b-256 81e3e49c89a4230973638854d9fa7de4eec5c6f81e610436e2587e30f38a6f29

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-0.12.0-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 8b79eb020c1b8d0ca27e69265ff908d6fb1c264c887ce5cf467fea5fbd72a84b
MD5 15146009d4f96296675f08e227e92e9c
BLAKE2b-256 ac8a97322084bf5e7045f0057549807286c9d9ece8c487197fc22fbf4ec1ae72

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-0.12.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2ae6e2eb5fb5b28c59d0c38e62189f219f174c42dc7344326f463ed1acec6eae
MD5 b15c6ebf76ce59ebc08e881260dca666
BLAKE2b-256 8ecb8c22ae8e5bb656d52ad13870eb9d623d7508a94bdd6ad9454523378cf380

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-0.12.0-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 163ab86f07e9bdb6e7eaea4fe81e75ecd82d6470a34ac5f74243127d645fc008
MD5 6f55c5a0652c921faf6c973f25739a9c
BLAKE2b-256 d0706005a5f42440191297efb2d17c64473611195d2baf1524a6a037afc64f53

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