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

Uploaded CPython 3.13Windows ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.12+ x86-64

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

Uploaded CPython 3.12Windows x86-64

pydantable-1.6.0-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.0-cp312-cp312-musllinux_1_2_aarch64.whl (19.0 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.12+ x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.12+ x86-64

pydantable-1.6.0-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.0.tar.gz.

File metadata

  • Download URL: pydantable-1.6.0.tar.gz
  • Upload date:
  • Size: 224.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.6.0.tar.gz
Algorithm Hash digest
SHA256 0080bf06578562a37c65c3877c2afea8bd339be1178297f6d6b22678060f1cc0
MD5 a26f3cb3b75e479a1c0c2d21ca94a501
BLAKE2b-256 b234b028e2dbfb75bb9a633c88c8752deab044cae1cac3965816bfeee9bc1cdb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pydantable-1.6.0-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.0-cp313-cp313-win_arm64.whl
Algorithm Hash digest
SHA256 e9e271fd43a3af4db55779beddb2e637d2bf7e8a84ce63c353c74c8324f8401d
MD5 9bbc0103036fbc9c85a3294cc5c59971
BLAKE2b-256 785c25cee568d70915a650a7ab52187451dfb4249ff7ad232a46954a98c6f827

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.6.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 920e8c861488d26debe2e29396cc7b67272cb6c39338e109e8f48d075355be0c
MD5 151fade04aad1f0b492a111cb3e86ef2
BLAKE2b-256 6417fb2d0a2a83ca4ab9e04186ff78679dc7a9d70c0bceb1a428fcae584e5798

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.6.0-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 2407b916c2303e01fbb7b9bc5ffe548d6f7ea3b4612f30d66030aa55d812db62
MD5 51bf2f237642d9aac0d673f69a7b142e
BLAKE2b-256 4c5313fa3bdaddd4ea26973b9325d1466a401bbf7b0dfeb48d34a1d3219f74f7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pydantable-1.6.0-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.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 a13a07469589e4012f83b5a8a055d910cf52e16464139c23b1f0e8b6d3fe4eee
MD5 b1754633d1fe7a75971f151bca53ce3d
BLAKE2b-256 d05c13319bf015cc605c820965531822a0dfdfaa7e325bfc44654864e34b9281

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.6.0-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 cde9a457cecd36be520d76351abbf79b83441c33277c311b63f8ae09a808b58a
MD5 138c8562da088f2ad05dc54b25c6290b
BLAKE2b-256 b437ba40adaaf56bd17a5ee2183badba79f4724f54035729f0935f7a080fc1fe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.6.0-cp312-cp312-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 a17c0ccc59eb1a675655ee5d8d5954a68a1e56c612f7f3c3d196cd7ab7198996
MD5 96bf661aab243bdf09c29d49270d69e6
BLAKE2b-256 f44e28ce13b6dd3bfd4eff25f80d44955acd395cd4c35cc63701eadcb81b20b4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.6.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5f7fa217f8cc955669840e1878955d537001f6dacc6750879ac650da7dacb2f1
MD5 9e21075e3ad360069d5829229b23c02f
BLAKE2b-256 f28355d1a2cdf7e7b10aff84783a981840ed2bc6ffd2ac6d049fef657193980e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.6.0-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 5c6b313375838655bdb8c31653ecf55a25eff3f0c635b6ef6179dab30c65dcee
MD5 db4e5c368300843d98a60ccc68a87d4a
BLAKE2b-256 2a0c8cf73d5bf053aa4275adb998cedccc4fd9cda8f713c3e443f3769a07d544

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.6.0-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 754637e8467389885944ca5f88b90a77326d055c34c1254b41f2fd212de16804
MD5 a36c151a9c6b0a5fecd84938cb34b3c8
BLAKE2b-256 9968f92dd0b772419308578996e3f82de2c6b2e17aae7e1baa8b26f95506f920

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.6.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 70b15ccc6e6b75128b37ea759af2244db20bec1bb059d44c7e139490bbf12fe8
MD5 d1de0cd126d5a6070a6c2dd1f1971f14
BLAKE2b-256 b6a201528ce451051846a98edb4551b61feae032946d941838daa88bd2659967

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.6.0-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 b9eee9506ed3e2e61af0a29e9f7743eef7fab8514ae0e1a28ee0bcb352dad144
MD5 861715e9065ad5e13aa723b9753cf2b7
BLAKE2b-256 70e42265fb204f4456176fbcb6dc9745c6479d4a01cec8f827540f27948d6582

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.6.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 dc48d01e64303e1e834d353abdc276f21a962351d11bab1ef0446011384d3cb3
MD5 7d95ca88ab3169391212c955a4bae9c7
BLAKE2b-256 24968cb963ae3bd587aa69019a9f393d91756711ccea2067d51ecd6fc7404294

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