Strongly-typed DataFrames for Python, powered by Rust.
Project description
PydanTable
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) orDataFrame[YourSchema]. - Typed expressions:
Exprand 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(), columnardict[str, list], or Polars/PyArrow with the right extras. - I/O: lazy
read_*/aread_*, streaming writes, NDJSON/JSON Lines, Parquet, CSV, IPC, HTTP, SQL (SQLModel-firstfetch_sqlmodel/write_sqlmodel, explicit string SQLfetch_sql_raw/write_sql_raw, or deprecated unprefixed names) — I/O overview, IO_SQL, SQLModel roadmap, 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]" # SQLModel + SQLAlchemy: fetch_sqlmodel, write_sqlmodel, *_raw, …
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 (
pluginsinpyproject.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]: lazyread_*/aread_*,export_*,write_*, SQLModel I/O (fetch_sqlmodel,write_sqlmodel, …); eagermaterialize_*and SQLfetch_*/iter_*patterns live onpydantable.io— passdict[str, list]into constructors for typed frames.- Scripts: raw helpers (
ScanFileRoot, iterators) onpydantable.iofor glue code. - SQL details: IO_SQL (recommended APIs,
*_raw, deprecations) and SQLMODEL_SQL_ROADMAP (phased migration). - 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(defaultTrue). - Validation presets:
validation_profile=...(or__pydantable__ = {"validation_profile": "..."}). - Per-column and nested strictness: {doc}
STRICTNESS(field policies + profile defaults).
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 |
| SQL (SQLModel, raw string SQL) | IO_SQL · SQLMODEL_SQL_ROADMAP |
| Pandas-like API | PANDAS_UI |
| FastAPI path | GOLDEN_PATH_FASTAPI → FASTAPI → FASTAPI_ENHANCEMENTS |
| Service ergonomics (OpenAPI, aliases, redaction) | SERVICE_ERGONOMICS |
| Custom dtypes | CUSTOM_DTYPES |
| Strictness | STRICTNESS |
| 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pydantable-1.13.0.tar.gz.
File metadata
- Download URL: pydantable-1.13.0.tar.gz
- Upload date:
- Size: 312.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
54f22c2d231ddfcd38518588a911799990dff521acfa2aa76546fca4e74a76d0
|
|
| MD5 |
c364dc2660a45d078e7d56daffae523e
|
|
| BLAKE2b-256 |
245b95bf52f8f8a8687189dd770ce46927c45288c414b38de57135a176c69d29
|
File details
Details for the file pydantable-1.13.0-cp313-cp313-win_arm64.whl.
File metadata
- Download URL: pydantable-1.13.0-cp313-cp313-win_arm64.whl
- Upload date:
- Size: 21.2 MB
- Tags: CPython 3.13, Windows ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b5cac0905abdb0bdedd20276d5362081c680d99cd052da58b0bcc32247b293f
|
|
| MD5 |
5aa80ca608d70b8f5545e39b295ae9a5
|
|
| BLAKE2b-256 |
127ae31370e4f804184cb9300a9d7d2b3d3e30ce3ccb2c46eea9ffc22b102671
|
File details
Details for the file pydantable-1.13.0-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: pydantable-1.13.0-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 21.1 MB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
66cca3d67b16bcba98628d29e606c7ae4a3d877bd5edd7c1d34812a6eac1bb41
|
|
| MD5 |
8fe2a64890658500ba2b2db24648f24d
|
|
| BLAKE2b-256 |
da6a7d954be62ee0558ec211b5e2d2f2591e4c8351a021f840e5d2e6f1c04302
|
File details
Details for the file pydantable-1.13.0-cp313-cp313-macosx_10_12_x86_64.whl.
File metadata
- Download URL: pydantable-1.13.0-cp313-cp313-macosx_10_12_x86_64.whl
- Upload date:
- Size: 22.9 MB
- Tags: CPython 3.13, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b384070f1db30ee3efffae4f5c9a20fb6a2342a3a684b4690e33043b9808154b
|
|
| MD5 |
8577155062ef31e6106e04a7fb0e6236
|
|
| BLAKE2b-256 |
df8ab61fdaf5ed434a42ca9b80c90e4968402590942915dcd26749d820affffd
|
File details
Details for the file pydantable-1.13.0-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: pydantable-1.13.0-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 23.2 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0fa42e8f4a5bce124959e571cd5dcf2e673e266da1d4dfe452ae2699707b6854
|
|
| MD5 |
aff66ef882a721c4633e80f28b06491d
|
|
| BLAKE2b-256 |
265ebf53fca56ad899e674e911af194d54afee499eb745e53ac229624de00c7c
|
File details
Details for the file pydantable-1.13.0-cp312-cp312-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: pydantable-1.13.0-cp312-cp312-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 21.2 MB
- Tags: CPython 3.12, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
108aabe6101328926db2780745a0bfecb13116206f001cfdec12711af7f783d6
|
|
| MD5 |
b02ea0f2e53ac2fa484a31387dadc06d
|
|
| BLAKE2b-256 |
ff9247faeb46c1191d34e93d97bd2278e5e02b2b9b45790fb0715caac68d2ab5
|
File details
Details for the file pydantable-1.13.0-cp312-cp312-musllinux_1_2_aarch64.whl.
File metadata
- Download URL: pydantable-1.13.0-cp312-cp312-musllinux_1_2_aarch64.whl
- Upload date:
- Size: 19.4 MB
- Tags: CPython 3.12, musllinux: musl 1.2+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32f3b0ccc0ec6f4b814e648ea0b23c1b02cb6f5e2788a53ac8d5a8ad89cd91fe
|
|
| MD5 |
dcc165073d42c90d4946bb6cef412377
|
|
| BLAKE2b-256 |
46dc94dce996445b76cf2536847351df00acaa0ab9c0e19821eb6c505e9ce7f3
|
File details
Details for the file pydantable-1.13.0-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: pydantable-1.13.0-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 21.1 MB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
559d30a7cd3e2fc1ab1d7e15a18f2d9a7463098d35f77c5bbe8ac5713fe87435
|
|
| MD5 |
c2d9ed0ce2ae5019fd97d75196c746c1
|
|
| BLAKE2b-256 |
5f3d26fe52885ae59e20de9a736869c97ee2f9bd767db6885457cd9d13ed9b69
|
File details
Details for the file pydantable-1.13.0-cp312-cp312-macosx_10_12_x86_64.whl.
File metadata
- Download URL: pydantable-1.13.0-cp312-cp312-macosx_10_12_x86_64.whl
- Upload date:
- Size: 22.9 MB
- Tags: CPython 3.12, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
506a22e6231e86bf9489b90cb1a3b840b81fa86a6e61f5da5aae8511b56aa245
|
|
| MD5 |
bc6c0d403060140550872dedc471d384
|
|
| BLAKE2b-256 |
aebf635740e0c3a812f6a3c77c7598c4887eba803c77bc77c7e040434cbb28a0
|
File details
Details for the file pydantable-1.13.0-cp311-cp311-manylinux_2_28_aarch64.whl.
File metadata
- Download URL: pydantable-1.13.0-cp311-cp311-manylinux_2_28_aarch64.whl
- Upload date:
- Size: 22.0 MB
- Tags: CPython 3.11, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e7ac21b40518c169ea78dfba4b2c6fa80f01ce73930b99a010f2844ff5f6540
|
|
| MD5 |
f76f611044a2b011078a93001b92221a
|
|
| BLAKE2b-256 |
bfcb64faa855f36da0bff697c6c5f3eae570e52927b8da7869e42646d7295a77
|
File details
Details for the file pydantable-1.13.0-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: pydantable-1.13.0-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 21.1 MB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05ae878035641786a6b62c5bb2bf4d860d17ad23fe3569cd3e48cb74336e80ba
|
|
| MD5 |
cd7c5c361e016649d05cd6e67344d94c
|
|
| BLAKE2b-256 |
839a2587eeb3267c928b5c3ec764961550800c6380ff9741fba7e1142d72b81f
|
File details
Details for the file pydantable-1.13.0-cp311-cp311-macosx_10_12_x86_64.whl.
File metadata
- Download URL: pydantable-1.13.0-cp311-cp311-macosx_10_12_x86_64.whl
- Upload date:
- Size: 22.9 MB
- Tags: CPython 3.11, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c92e52fdb6baf061b10d41e601c31591ec3f748fd3a0fd0cd5a0b57b17f5074
|
|
| MD5 |
9fa80e64c385d1e423a92dbdb89c6fe8
|
|
| BLAKE2b-256 |
b31580f0d8504bdcccc6aa2a5e53206acf5e6d5de42b5bb839d28e74a54ed5c5
|
File details
Details for the file pydantable-1.13.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pydantable-1.13.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 23.2 MB
- Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c6f64bf12a96876a88469244405664602dece6101b78a3f4dfc6315e8036dbd8
|
|
| MD5 |
ea8a66e061fcebd2b08a23e99157f8e5
|
|
| BLAKE2b-256 |
406652c4c414d338cc4c789e4a9e965382ffc2abb4a8f6eb9801b9d87cfab3b6
|