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 workflows for Python services, with Pydantic schemas and a Rust execution core.

Why PydanTable

  • Define table shape once using Pydantic types.
  • Catch many errors early with typed expressions.
  • Use familiar DataFrame operations (select, filter, join, group_by, windows).
  • Materialize as row models or dict[str, list], depending on API needs.
  • FastAPI: optional pydantable.fastapi helpers — shared executor lifespan, NDJSON streaming from astream(), OpenAPI-friendly columnar bodies (columnar_dependency / rows_dependency), and register_exception_handlers (503 / 400 / 422 for common failures). See the FastAPI guide and golden path.

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[fastapi]" # FastAPI integration helpers (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())   # {'id': [1], 'age2': [40]}
print(result.collect())   # list of Pydantic row models

Core concepts

  • DataFrameModel: SQLModel-like table class (class Orders(DataFrameModel): ...).
  • DataFrame[Schema]: generic API over your own Pydantic BaseModel.
  • Expr: typed expressions used in transforms.
  • Errors: predictable ingest failures such as column length mismatch raise ColumnLengthMismatchError (subclass of ValueError) from pydantable.errors; map to HTTP 400 in FastAPI via register_exception_handlers.
  • Static typing:
    • mypy can infer schema-evolving return types for many transform chains (via the mypy plugin).
    • pyright/Pylance relies on shipped stubs; use as_model(...) / try_as_model(...) / assert_model(...) when you want an explicit after-schema model.
  • 1.2.0 column types (typing.Literal[...], ipaddress IPv4/IPv6, WKB, Annotated[str, ...]) are documented in SUPPORTED_TYPES (including Expr comparison notes).
  • Materialization:
    • collect() -> list of row models
    • to_dict() -> dict[str, list]
    • to_polars() / to_arrow() with matching extras installed

I/O at a glance

  • Default: DataFrameModel / DataFrame[Schema] — lazy read_* / aread_*, export_*, write_sql / awrite_sql, …; eager materialize_* / fetch_sql / iter_sql live on pydantable.io → pass dict[str, list] into constructors for typed frames.
  • Lazy file pipelines: MyModel.read_* / await MyModel.aread_* → transform → write_*
  • The pydantable.io package exposes raw helpers (dict[str, list], ScanFileRoot) for scripts and glue code — see IO_OVERVIEW in the docs.

Validation controls

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

Documentation

Development

Create and use a virtual environment at .venv in the repo root (the Makefile defaults to .venv/bin/python). Contributor setup, Maturin/Rust builds, and release workflow: DEVELOPER.

make check-full

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

Uploaded CPython 3.13Windows ARM64

pydantable-1.8.0-cp313-cp313-macosx_11_0_arm64.whl (20.9 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pydantable-1.8.0-cp313-cp313-macosx_10_12_x86_64.whl (22.8 MB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

pydantable-1.8.0-cp312-cp312-win_amd64.whl (23.1 MB view details)

Uploaded CPython 3.12Windows x86-64

pydantable-1.8.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.8.0-cp312-cp312-musllinux_1_2_aarch64.whl (19.3 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ ARM64

pydantable-1.8.0-cp312-cp312-macosx_11_0_arm64.whl (20.9 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pydantable-1.8.0-cp312-cp312-macosx_10_12_x86_64.whl (22.8 MB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

pydantable-1.8.0-cp311-cp311-macosx_11_0_arm64.whl (20.9 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pydantable-1.8.0-cp311-cp311-macosx_10_12_x86_64.whl (22.8 MB view details)

Uploaded CPython 3.11macOS 10.12+ x86-64

pydantable-1.8.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.8.0.tar.gz.

File metadata

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

File hashes

Hashes for pydantable-1.8.0.tar.gz
Algorithm Hash digest
SHA256 440c56ac51d33d1713c4e2917f4c52299d51fc7cc928aa3140a5a74e349a3718
MD5 21be28c1d9a5dd1b2744da5e6706e664
BLAKE2b-256 d263146891a03620fd9ffa08114dd30a66c75dbb51634b9fdf763d84857f2663

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pydantable-1.8.0-cp313-cp313-win_arm64.whl
  • Upload date:
  • Size: 21.1 MB
  • Tags: CPython 3.13, Windows ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.13.11

File hashes

Hashes for pydantable-1.8.0-cp313-cp313-win_arm64.whl
Algorithm Hash digest
SHA256 9e0c842fd66ad8c7254ff40e1ffccf39f54fe3206fadc14999355fd41d3a757d
MD5 13b95df8780c90935ef1d45d5201f3b5
BLAKE2b-256 4a4ccf0842c1ce0574e2918d1b4e41444c3cba47f17f9aab0cd0322b4aa9c7ca

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.8.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9ad1a5810bcd5275ac23ade3f1f3b0047951df9307b2da0aefd562327c927eae
MD5 5fc493c851fe8236d1792bd097fd07a5
BLAKE2b-256 c9bcddd6728e717990e00c7fe72a25d22cae1ce401e175f1a7fa0fb0099ac445

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.8.0-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 ce5934fe81f0766a8e1185ffbdef9d28443a0958d03e98ac0fb31d09009e78b5
MD5 c9d6984913e488542578cec1f5691945
BLAKE2b-256 742c940f825f041faaae876276004dc552dedbc98d004d01ceb49783b4400fea

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pydantable-1.8.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 23.1 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

Hashes for pydantable-1.8.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 584f03b01c1da1ad819ee5a5abea577a82050ac2767cebd1d7059152c2faefcc
MD5 21dce69793c3674b60ca0346ce82cf0d
BLAKE2b-256 fca5014dfdde9d7748a87b757b23b51875c361673919051567b510d844d7400d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.8.0-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 2143d5c4397f70c01e21a471f363df7d4a47f121dbfdcb16972c48eba0b310cb
MD5 f07c6075152518ed90bf524b1c0f6a53
BLAKE2b-256 0361d37d726a4b65341cc7265deb761b81b998223cc5f685c9cbe9f16db95289

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.8.0-cp312-cp312-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 368bf5aafad9b6a02e3f10f318f1244098c4f255ec7d6cad2a8f1ad3f69c3c84
MD5 50a32af50d408afc039f4c0e5cdb5e23
BLAKE2b-256 0c0e85ae2d2ef4d8295af4ed24a006875e9d79d880a1e6ef424122299c660c12

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.8.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3e4236c8d28298ecd13d3cd4d4b4cacc677be332d16b25287259a13631df98ce
MD5 744287c8fd73af6f4a701c2047400696
BLAKE2b-256 15ef1194f90902b90bc3f0cea9b0cf541b5498d3cba4c371f035bee3a63898f6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.8.0-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 39fd916fd880ac66908f6b203433b67c90c84c9c62569bbd4d6162eeaec2661d
MD5 5a03c97288d6ec446781e14c5bcab5e5
BLAKE2b-256 6872854ba6ed59f585a8cea4124ca3b5ef29172b10505f54199a9ae3a421da0c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.8.0-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 990d4d9b28a41f26811960152abb490a47fd2241ce6c5e79897528f0ac51daec
MD5 bcfd8a850c7a7255102523dbd386a9df
BLAKE2b-256 7b141f397231042bc020264cb735d0c63ed821b8000c0f96dd658076cc4dc679

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.8.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d2ca0d9a02b1e5abb9f92860e400e921ded131806ecd22acc17285bfde53a4df
MD5 31a0095d8a541dba66e42af93181bd0e
BLAKE2b-256 86300377be4bf6c228db0c12653567d07a6b66047ec9d8b127ba20acafac3f7c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.8.0-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 88550d0f6f3bb10d0b4a51493ffa909c90c7b1a9084068779dc5bcb10113e421
MD5 3c3c459358e07b0c2efdfd6aa697fe73
BLAKE2b-256 f81e0d0a08a2d4f1df2b9fa2b82680f18673b2385225f4c4dd5c0cc72f60d686

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.8.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 efd859fc5aa078d8e9bdbb0e8c8d5df07ebfdf4d105fa6edcca0a22637213cc8
MD5 e8e3347171dfd9982555082c024d348b
BLAKE2b-256 abaa0bf1eb0a7b2273fe15a8684090f0b2820a0e29c7f554c5e40ca1ad5379b9

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