Skip to main content

Strongly-typed DataFrames for Python, powered by Rust.

Project description

PydanTable

CI Documentation PyPI version Python versions License: MIT

Strongly typed DataFrames for Python, powered by Rust — Pydantic schemas, Polars-backed execution in the native extension, and an API built for services (including optional FastAPI integration).

Why PydanTable

  • One schema, many surfaces: define columns with Pydantic models; use DataFrameModel (SQLModel-style) or DataFrame[YourSchema].
  • Typed expressions: Expr and transform chains are validated and lowered in Rust; many errors fail fast at build/plan time.
  • Familiar operations: select, filter, join, group_by, windows, melt/pivot, and pandas-flavored helpers where they help.
  • Flexible materialization: row models via collect() / rows(), columnar dict[str, list], or Polars/PyArrow with the right extras.
  • I/O: lazy read_* / aread_*, streaming writes, NDJSON/JSON Lines, Parquet, CSV, IPC, HTTP, SQL — see the I/O overview and decision tree.
  • JSON & struct columns: struct expressions, JSON encode/decode helpers, unnest/nested models — IO_JSON, SELECTORS, roadmap story.
  • FastAPI (optional): shared executor lifespan, NDJSON streaming from astream(), OpenAPI-friendly columnar bodies, register_exception_handlers (503 / 400 / 422). Start with the golden path and FastAPI guide.

Install

pip install pydantable

Common extras:

pip install "pydantable[polars]"   # to_polars
pip install "pydantable[arrow]"    # to_arrow / Arrow constructors
pip install "pydantable[io]"       # full file I/O convenience (arrow + polars)
pip install "pydantable[sql]"      # fetch_sql / write_sql helpers
pip install "pydantable[pandas]"   # pandas-flavored façade (pandas UI doc)
pip install "pydantable[fastapi]"  # FastAPI integration (pydantable.fastapi)

Quick start

from pydantable import DataFrameModel

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

df = User({"id": [1, 2], "age": [20, None]})
result = (
    df.with_columns(age2=df.age * 2)
    .filter(df.age > 10)
    .select("id", "age2")
)

print(result.to_dict())
print([r.model_dump() for r in result.collect()])

Output (exact values depend on filtering; this matches scripts/verify_doc_examples.py):

{'id': [1], 'age2': [40]}
[{'id': 1, 'age2': 40}]

Core concepts

Piece Role
DataFrameModel Table class with annotated columns (class Orders(DataFrameModel): ...).
DataFrame[Schema] Generic API over your own Pydantic BaseModel.
Expr Typed expressions in with_columns, filter, etc.
Errors Ingest issues such as column length mismatch raise ColumnLengthMismatchError (ValueError subclass) from pydantable.errors — map to HTTP 400 in FastAPI via register_exception_handlers.

Static typing

  • mypy: schema-evolving return types for many chains via the bundled mypy plugin (plugins in pyproject.toml).
  • Pyright / Pylance: use committed stubs under typings/; for explicit targets, as_model(...) / try_as_model(...) / assert_model(...). See TYPING.

Rich column types (Literal, ipaddress, WKB, Annotated, …) are covered in SUPPORTED_TYPES.

Materialization: collect() / rows() → row models; to_dict()dict[str, list]; to_polars() / to_arrow() with matching extras.

I/O at a glance

  • DataFrameModel / DataFrame[Schema]: lazy read_* / aread_*, export_*, write_*, SQL helpers; eager materialize_* / fetch_* patterns live on pydantable.io — pass dict[str, list] into constructors for typed frames.
  • Scripts: raw helpers (ScanFileRoot, iterators) on pydantable.io for glue code.
  • Large files & NDJSON patterns: IO_JSON, IO_NDJSON, EXECUTION.

Validation controls

  • Strict by default on constructors.
  • Optional ingest controls: trusted_mode, ignore_errors, on_validation_errors.
  • Missing optional fields: fill_missing_optional (default True).

Documentation

Topic Link
Docs home pydantable.readthedocs.io
Map of all pages DOCS_MAP
Quickstart QUICKSTART
DataFrameModel DATAFRAMEMODEL
Typing (mypy vs Pyright) TYPING
I/O overview IO_OVERVIEW
Pandas-like API PANDAS_UI
FastAPI path GOLDEN_PATH_FASTAPIFASTAPIFASTAPI_ENHANCEMENTS
Cookbooks Cookbook index (FastAPI, lazy pipelines, JSON logs, …)
Example multi-router app docs/examples/fastapi/service_layout/ in this repo
Test helpers pydantable.testing.fastapi — see FASTAPI
Execution & async EXECUTION · MATERIALIZATION
Behavioral contract INTERFACE_CONTRACT
Troubleshooting TROUBLESHOOTING
Versioning VERSIONING
Changelog changelog

Development

Use a virtual environment at .venv in the repo root (the Makefile defaults to .venv/bin/python). Full contributor setup, Maturin/Rust builds, and release notes: DEVELOPER.

make check-full      # ruff, mypy, pyright, typing snippet tests, Sphinx, Rust

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-1.10.0.tar.gz (294.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-1.10.0-cp313-cp313-win_arm64.whl (21.1 MB view details)

Uploaded CPython 3.13Windows ARM64

pydantable-1.10.0-cp313-cp313-macosx_11_0_arm64.whl (21.0 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pydantable-1.10.0-cp313-cp313-macosx_10_12_x86_64.whl (22.9 MB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

pydantable-1.10.0-cp312-cp312-win_amd64.whl (23.2 MB view details)

Uploaded CPython 3.12Windows x86-64

pydantable-1.10.0-cp312-cp312-musllinux_1_2_x86_64.whl (21.1 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

pydantable-1.10.0-cp312-cp312-musllinux_1_2_aarch64.whl (19.4 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ ARM64

pydantable-1.10.0-cp312-cp312-macosx_11_0_arm64.whl (21.0 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pydantable-1.10.0-cp312-cp312-macosx_10_12_x86_64.whl (22.9 MB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

pydantable-1.10.0-cp311-cp311-manylinux_2_28_aarch64.whl (21.9 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

pydantable-1.10.0-cp311-cp311-macosx_11_0_arm64.whl (21.0 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pydantable-1.10.0-cp311-cp311-macosx_10_12_x86_64.whl (22.9 MB view details)

Uploaded CPython 3.11macOS 10.12+ x86-64

pydantable-1.10.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (23.1 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

File details

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

File metadata

  • Download URL: pydantable-1.10.0.tar.gz
  • Upload date:
  • Size: 294.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for pydantable-1.10.0.tar.gz
Algorithm Hash digest
SHA256 be4af719bb7d94805f6078667692bdb85940c0c8deef4d82e37fb622586cf3f3
MD5 fbbb74ee9892f1d4e0560a9eac028a81
BLAKE2b-256 a7503353e6f4a1775642a534c2fe505b39561e221af7da5e37b66afc5d4c789c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.10.0-cp313-cp313-win_arm64.whl
Algorithm Hash digest
SHA256 e071bc0f5d020dcd8c377f6c0eea6b00e779882305cb3aa4ef2b0463d44caefd
MD5 17d82f111573029aabf0d030b48ac879
BLAKE2b-256 4c1339ef47edacb3f111280abead97b3457aa75b9a925552077aac7338ab2f7a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.10.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3b6083d67878d72f3717031fc682aca8a20f466d193587b4dc37608c62fcd2a4
MD5 966d284f46bcea9d66455eedc6e28f71
BLAKE2b-256 a10a6fa393f3f8b6f688bd8c144f167165646d4475befa15c543be9a13f413f2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.10.0-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 eeddcbe6b04512354ae1df5c84b34664425ca8f2627cd57a4c53a9acf9b2d431
MD5 f6b3c6a58ca53d76b03de172d17d82f1
BLAKE2b-256 415e3a6736c54a96dcac4ac8811b03e6df3722d5a4145ca8866ed6bbea22f191

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.10.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 f4fa2971056e149f7b32ce857d6e34db5702a60210b08107c3976f0df5348486
MD5 09b78f4ff79fd18fc7b4e105c5821010
BLAKE2b-256 5397afa48d1d34dfbeb4e33a8a1fd15b11424a90319142e8de58d8f09a03d42d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.10.0-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 aef69a4d5e94dca44ed283fe970a8a77f40ca812ea3fc8df091c5a6bcedc3b0f
MD5 7530682234460210ffeab6a1d42467a3
BLAKE2b-256 867f0beb23ef5661a0a6b1153ce4addb5350ebed0dcd82a3727332864912c2d6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.10.0-cp312-cp312-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 084496681633a4cd5548b9ea0acbbefe1b57190ab7fdaf2d023d47abfd9d2835
MD5 33875cc0a9f9704e55fecfad91cf0e8a
BLAKE2b-256 6426ab993b3b195d608b89176257e0ddad04e7a5e281400ba2533b7defc2ee6c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.10.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f5d65eade636b768dd4a10d51e9d3bc813a00ce3059e8dc4e7cccd47e6d50862
MD5 2e3e0a314d83fbf33d2d8346864670ef
BLAKE2b-256 d8d2cd578488fadc5165afc0fe1595719840259b49f25dc60760522d4ecbda61

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.10.0-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 eab47c62420b61a7dc914e46d28ab3cd62fb57761a792707d21f95d4a04ee526
MD5 05c5536d9b879a97a24a82a6e16fbb79
BLAKE2b-256 2affbf6b1579b9bfbb8fbb506eadec5028e25bdf1a385dec021c177d0db42d09

See more details on using hashes here.

File details

Details for the file pydantable-1.10.0-cp311-cp311-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pydantable-1.10.0-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 3dc6eb5a368e6d4a059c96e5b4962b6c542b52c5e1fbeb727a06f22998c710b2
MD5 465562a1b7cfab88facf333f4d2d22a4
BLAKE2b-256 042140c742179103ab7bf8c4609b06faae634d448edb9f92c6d8ca978ed20268

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.10.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 424e632a581fe5c8035565daaf2e86a9b418a8ea178b866a2e74baec2771d43e
MD5 165b0d14a3a6205f549c078edca445e4
BLAKE2b-256 931041149536ec2a5a1f2651645b0343f743b8d1a022ae8c246a2dd162c3cb18

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.10.0-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 3c2c3dcb9915cd9678eda330a49ec23762f0edab2ab3c26944d4c91f11585603
MD5 004e913f54cee5bb2d8f92877d146974
BLAKE2b-256 e787fac72a51c85d367ee4af2788f6d4badceb64853f179440118431a9ebc56c

See more details on using hashes here.

File details

Details for the file pydantable-1.10.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pydantable-1.10.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0902b5a0c4e73d806f1ad90b5e25224899c752b36a6cf03d7e2f1cb2faf72b87
MD5 1e3e2ab3308c3d48a813d41bc8fef624
BLAKE2b-256 7de50de47dc2659bd07b6de473e3f40707907300e0479e1e1173f86a14ec858d

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