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.6.1.tar.gz (227.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.6.1-cp313-cp313-win_arm64.whl (20.7 MB view details)

Uploaded CPython 3.13Windows ARM64

pydantable-1.6.1-cp313-cp313-macosx_11_0_arm64.whl (20.6 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pydantable-1.6.1-cp313-cp313-macosx_10_12_x86_64.whl (22.4 MB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

pydantable-1.6.1-cp312-cp312-win_amd64.whl (22.7 MB view details)

Uploaded CPython 3.12Windows x86-64

pydantable-1.6.1-cp312-cp312-musllinux_1_2_x86_64.whl (20.7 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

pydantable-1.6.1-cp312-cp312-musllinux_1_2_aarch64.whl (19.0 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ ARM64

pydantable-1.6.1-cp312-cp312-macosx_11_0_arm64.whl (20.6 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pydantable-1.6.1-cp312-cp312-macosx_10_12_x86_64.whl (22.4 MB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

pydantable-1.6.1-cp311-cp311-manylinux_2_28_aarch64.whl (21.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

pydantable-1.6.1-cp311-cp311-macosx_11_0_arm64.whl (20.6 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pydantable-1.6.1-cp311-cp311-macosx_10_12_x86_64.whl (22.4 MB view details)

Uploaded CPython 3.11macOS 10.12+ x86-64

pydantable-1.6.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (22.7 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

File details

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

File metadata

  • Download URL: pydantable-1.6.1.tar.gz
  • Upload date:
  • Size: 227.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.6.1.tar.gz
Algorithm Hash digest
SHA256 503da59a87e474a8c83dd0df2d1e4fdbc4b4dd9a656edd73111508cb5b1ced60
MD5 b6a6634f69ff681e3a585e5b59805edd
BLAKE2b-256 f9bafe794af6634770a67cae67b44c55c10b1da160f1055cff59b081b3e61019

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pydantable-1.6.1-cp313-cp313-win_arm64.whl
  • Upload date:
  • Size: 20.7 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.6.1-cp313-cp313-win_arm64.whl
Algorithm Hash digest
SHA256 89b6be95a29293fb9cd878422fa6ab40b55bca7cfc67be4f472b7c9f73054d68
MD5 c11d4ec0cc95fb01168249852dea3e76
BLAKE2b-256 8efba7ae6108d7a939747b1491a264a74a0ff69d0ef8c96d66050efb057e42ab

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.6.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c0a27731cd9f0c8ec407a4627ecdf5972fc81c3a01893fff1c28cb535ce52a0f
MD5 35bd3ccef8d98d012782531599ab0fab
BLAKE2b-256 9c7cbf13963b0c0fbee893c451eaa04906b63aac75933d79db5cfd0b8d3072cb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.6.1-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 559c2e4ea329160279c45933970b7be6ecb75081eaaabea98378012cce15cc13
MD5 ef369282809054a490c388d7c888c697
BLAKE2b-256 170cfcefb7a71ce4d20a44020f7f9e6b1f8cf1d0d76dd2b04ef47af72ecfe36e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pydantable-1.6.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 22.7 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.6.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 afe6c0bd74ab0e99adfa9bd517af4d9ecc86d8dc31040bc32a19a101e8fc9a2c
MD5 b73406cce068df24aabfbe8b8e833eee
BLAKE2b-256 b4145bb763d515b92947cdf8d53d3464ee9b098188b47e1f3a7831bd15069037

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.6.1-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 6f2e3fdfa2e97d5a7e5d6efddc0ae473f635c181c8c2c041c6709144682632d4
MD5 580f26d83494d24d72cb54cda43a57ea
BLAKE2b-256 a4f4968965c43b49a94765ff31e7e98130472835aa2ac4aac5e071e889aa3016

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.6.1-cp312-cp312-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 cadb6448e453d042e2c5c487abcedba8c5ba32c1e44b5bf45f02ec3320e8d0f3
MD5 582e8dc415cd5be23064f7c07042a4ab
BLAKE2b-256 42e619c29544463d1e3e9f9b54588ea8cf8ea3131bcff3f8ed4bf76f647c5652

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.6.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 69e48f95f150bbffd525d6c813582a66ecbbfa5b3f62ce0a73d9d26df279c181
MD5 bfc0ce6289c23c88b8488a571e3384d7
BLAKE2b-256 cb72f1d93962def618d1a6725c121caff003808f775e87b9d9a5d882abcc37ff

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.6.1-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a5caf385f19278e71bd096d1d8f6e1dae06333c31a1c7d4e14c5e20720bc3321
MD5 e953d2122a8a6a90aa78e937f319de57
BLAKE2b-256 bb8ae93f833ef7457aec4ffe47e58bd9f18285efd3c9f1407e93d64ba0854aac

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.6.1-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 de05448d236b26e3e8fd581f8e1513cdf10aa801488be3c8f2628452f730d71c
MD5 a7c7f61b6758ac9e7fb2f20f7e5d0397
BLAKE2b-256 d31025241e532ae317eeaaa0c4c3f7486829a6051c37fb12ee9d5c98bf361e7c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.6.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 669d8a3dc814f368432ced216a8a5494f012bb1c5c04b30fee8bc40381b29a9e
MD5 2f23c9569002f4a6b2861f5036a55702
BLAKE2b-256 6dd7da5c6271ad989b82fed48cfd19633ff014ce348a72397005407ce41c3b05

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.6.1-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 5bb6d43223e53cb5541a95542d8e28597e16fea1893a6663a34798c18b32f570
MD5 c774374100f3839135653fc7a06a4f86
BLAKE2b-256 244c5830ec90cb1b2eecf30f5cfaca0fcc923fc422af576dea9cae1c06163374

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.6.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 002ee576fe56b3360d43094fc91856ce9c7c146cd47781897d50cbc63f86e1cb
MD5 c9fc75a4b779cbbc1ab774c965083d77
BLAKE2b-256 ee1c923e2b4cbe4a1d74e0e3a8d8f91bd6392df3c334d1eba4fb22ae98ec6fc5

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