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

Uploaded CPython 3.13Windows ARM64

pydantable-1.11.0-cp313-cp313-macosx_11_0_arm64.whl (21.1 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.12+ x86-64

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

Uploaded CPython 3.12Windows x86-64

pydantable-1.11.0-cp312-cp312-musllinux_1_2_x86_64.whl (21.2 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

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

Uploaded CPython 3.12musllinux: musl 1.2+ ARM64

pydantable-1.11.0-cp312-cp312-macosx_11_0_arm64.whl (21.1 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.12+ x86-64

pydantable-1.11.0-cp311-cp311-manylinux_2_28_aarch64.whl (22.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

pydantable-1.11.0-cp311-cp311-macosx_11_0_arm64.whl (21.1 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.12+ x86-64

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

File metadata

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

File hashes

Hashes for pydantable-1.11.0.tar.gz
Algorithm Hash digest
SHA256 838456c2e382644c6b1aece0a8fb714a10b85fe0ecebb7543d96bcfed0b54d18
MD5 95c9ee6d9c395245f1139c0c6455afc6
BLAKE2b-256 8c4bb383f6d752361b78186426a51e25f1e8c4fdca8b8433b1eff862dee3abb6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.11.0-cp313-cp313-win_arm64.whl
Algorithm Hash digest
SHA256 631c39b3d96cc0f62e51bc99e7c925ccfa196042b5a81138a077c6b193fecd17
MD5 c52027961525cb4157a8a2fdb4f3244c
BLAKE2b-256 60b491e15eef7d8e8dd3a616c1fb5c85ae640d868ca1700d60780f09d6bcaeda

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.11.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2414b16c931845c701cf00ee3c6ac5e5d50f256305ab009bb0bbf5a61a558b22
MD5 5d5ce1fb0d3ff5d4e2a83c7cd6a9bb41
BLAKE2b-256 183c43f6db03dd356c0c37b2243bc6130e19a0e8626408f61b5380320e24c225

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.11.0-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 8db751430da66d97ce66c40cc7f8d3d2d34b1c9d58fe542a2b76663767bc5164
MD5 c26a060d1af8aff1d14f310d87ba36c8
BLAKE2b-256 4dacda602b1202445c0d90a175aeb7d292b1db98349074a5e8893efb5878dca1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.11.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 15bf73909c8688da16c3c887e0ac7e740163175a7a14600b9a8c4bbb63e7749c
MD5 0afec2c061b7e48d37dd76b0a534cf1f
BLAKE2b-256 bed6b43132a04068b7728f0636d69d3918d93bdec37eaf5ee1fd98a1d2cfaf3b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.11.0-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 6b0ff489e219373fa2bd18be1a4cb9cc3b71303660b8f662e14095c54a532b71
MD5 eb5f13ed27362856d77f222d79620162
BLAKE2b-256 3ea9555b96b936319b18d473124b0ef12f16a1eb2a12bb69fe12f47c1c785168

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.11.0-cp312-cp312-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 ff9af1f3efabb74bcc923720142e4c3a1d252fc948495400f641fbbb9c3de9e5
MD5 293a825a07da2f556460707cbf6e4c85
BLAKE2b-256 18d141a234ab92dad532dd21b1ab1cbc1cbbb5b543b3ef1d9d22353c6791fb3e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.11.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4789c8f11b2cef5d923852a5db44b0e596d3549f769545e12a58517bf4da8840
MD5 1a022a0d4f9ab5c3020ca2d136f453e5
BLAKE2b-256 591373c76affa9a68e6afdace9aa5453bd7ba358d6d2175fcecd8bab12ac33c5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.11.0-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 8c9f813584725b278a3d1c2df3fc83c4df65f0026bb9574e1017a71c3e6cbd03
MD5 10e313d699402e364e59e5c625f662b2
BLAKE2b-256 13d4949abfdf9f9b75e67b752180c2edca0f769038a90245d515e9fd92fd8d79

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.11.0-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 891640d75c8d6593b420c8d6a7de032e3c749cc2b22a20d99e5c7adb35b9cd78
MD5 28841c01156613f3c60eaa82278f5901
BLAKE2b-256 84f2173cc29684f849821e60e35239ecaa4849d940da745a4a9438cea20534b7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.11.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9a916ad8fbdd349d3d1445cde336a767c595541fb1fb1120b9d2479c1ca99063
MD5 c6bc56b87c8d234286ef9e998f1fb490
BLAKE2b-256 74a7931f87fc07dcc5d9f4ab2c101662369a2608a66c2421be6b9a75242262e8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.11.0-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 9d90ea4b4726ece89d9c4062eae9b89233a83abb78a19174852def55f0e89690
MD5 b5a70a04820e3e4da11118433afc576f
BLAKE2b-256 f8ab6b66086cadbc9de8ee3c73da0ffe74f305166a06a6604c1c9a2cd4a4ab57

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.11.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 969207dd9a6125353ca39faf1eba6776a28a5ea057b0d62192e649fc694a1ec6
MD5 2c727a8ebacf318e5f9fb45639619667
BLAKE2b-256 d81fdd7e1d754a6d4001190ef7b99f3ca857a3a06f9786209a10435ceceb1075

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