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

Uploaded CPython 3.13Windows ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.12+ x86-64

pydantable-0.11.0-cp312-cp312-win_amd64.whl (18.5 MB view details)

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12musllinux: musl 1.2+ ARM64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.12+ x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

pydantable-0.11.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.11.0.tar.gz.

File metadata

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

File hashes

Hashes for pydantable-0.11.0.tar.gz
Algorithm Hash digest
SHA256 ffa2618d66648c63fb6f2c180b92d9007289ee7d795b4f51661d9b788a19c5a3
MD5 7c04a3c3ecf4031033493a8b54d3afd1
BLAKE2b-256 c60e0b44737f373f0e110362165188052ab8b4ca2687922831a9b57d92d079ff

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-0.11.0-cp313-cp313-win_arm64.whl
Algorithm Hash digest
SHA256 699e755414562b6b2061e2009943a117f1bed65fbce4f5e4bdaac6174192caac
MD5 920b5a2b173815c6c6a8e93c812afb3b
BLAKE2b-256 5a4db55f1348e3e06a6b180f2ae1cdb6c2395978c7729ae10b613946b78418db

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-0.11.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 740df92552d2fa3566e4eaf5bb4746326c4aca92caf62617ae1b75bc7370dff7
MD5 88e2f5540780f62f80ca1abba03eafac
BLAKE2b-256 451f362274e1c76f4bc1dafef0a82a90d4f559230c11c2f8888b810484fa0563

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-0.11.0-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 102db24466f302e1605eca4b1b616679f7ee5acca22c14a0fb7445ac58d759e2
MD5 810669d316245ca12800126f3d45f290
BLAKE2b-256 de9b4404be57ff8424ea2dc9f406cc63b4027784de66c21f9b3aef9b2fc6bfd0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-0.11.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 8533f1f18fe031cc0b8bfed7a177a2ad13d8898e21921e9e34b53f65ac7fecc3
MD5 67fb4b0003ba5e62b2eac408cdf173df
BLAKE2b-256 787e3a9e1f4a201ef9e07fb859ef526229043f868ec4324d228baaf21a7e5b0c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-0.11.0-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 c7ab5460c2e140a5bdb4bd9a48ae2076598ce4b48d918df40f478ecae325d6c0
MD5 688e5d5284e7af3307e6791eb9d64e0e
BLAKE2b-256 dc984af729fa829cc1d692c59a76b60b4fd82beb9f4938ce514c0f54f2e9d987

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-0.11.0-cp312-cp312-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 ed6f7f2a70d6e5eef8ee4bbccac386c5511ac271756417b1b67575c2bf0adb3d
MD5 9f7405ceb3b359ed48a9e2858e07bdbd
BLAKE2b-256 3e8e12e967753b68f33d9eaf4f726274c57756fe91bf2fd9e23ef136c005acc8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-0.11.0-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 081bfc529f5e572fe6eb864313291aac4054304f570317c163d9f828c5f2eeb4
MD5 f52d7323d84180a3897883ffaf929e7e
BLAKE2b-256 71b44b88fd13ab69fc17a4697e02239de8b59e317999b8a243eb793be176155a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-0.11.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 73ba200186863d77e9c23bad12ee145ce85afea62fb4d7add81ffdf596108589
MD5 c93dcd466295d0cac6fec818098e762f
BLAKE2b-256 5495972a87c23c82c9529bb7683c3ada29c79f44d4678265dcf824544acbea01

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-0.11.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 76cc2571fd09f8477446114baa48f3d2ea8722dc5e63653590f01f7bb778b999
MD5 67f04a4a3a3a0e763e9fb774206467f7
BLAKE2b-256 44fd2a6f56ad68cd02e6aa16a5a112821b645e1e5bf7adab3853cf0baee1c404

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-0.11.0-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a324ca20160df57588c19bd7c0148ef2e8fd077d58b8c64b71047677610510ce
MD5 38d5ddd0d60885a77b122cc5749e3815
BLAKE2b-256 77601676d933ff8460b1ee21eff02d3b7005ebcfe7c92d98b598b3f1ce62300c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-0.11.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 70c9b177f614653fc08375b4eed72691b146c1190c4f208134794b3530b9e7c3
MD5 6b3648358646563b92cb479783302e15
BLAKE2b-256 33d0cfa932cc6fe3b18d3aa77e7033893a4fe0894c876c2042663c66b3ed3dec

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-0.11.0-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 8d7bc5d80bc87b602219e6dde7f9018bfacf9198801b7200e92fd9eb36d43277
MD5 44fc7b382c935db4108e2a0a102f76ce
BLAKE2b-256 e7ae6e95ed2e136c85b9ec7f06cffb7f99b8fbf9567846fcbcad1b5ea613c371

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