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

Uploaded CPython 3.13Windows ARM64

pydantable-1.9.0-cp313-cp313-macosx_11_0_arm64.whl (21.0 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.12+ x86-64

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

Uploaded CPython 3.12Windows x86-64

pydantable-1.9.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.9.0-cp312-cp312-musllinux_1_2_aarch64.whl (19.4 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ ARM64

pydantable-1.9.0-cp312-cp312-macosx_11_0_arm64.whl (21.0 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.12+ x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

pydantable-1.9.0-cp311-cp311-macosx_11_0_arm64.whl (21.0 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.12+ x86-64

pydantable-1.9.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.9.0.tar.gz.

File metadata

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

File hashes

Hashes for pydantable-1.9.0.tar.gz
Algorithm Hash digest
SHA256 78c223d902d1b9325d1cc8ecf4fe8b2a00d1be0b428c63f318be056c5d0f1b83
MD5 c3b2de1f53c548950f7105f077f0972c
BLAKE2b-256 129bd5205c18e9f6c22964e62cfff6e4a6063e894098333b6e10f4ed1bb13c98

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pydantable-1.9.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.9.0-cp313-cp313-win_arm64.whl
Algorithm Hash digest
SHA256 cffb6b5f272752a4346bb2aede77646134353a9de66ea57d1ac0d962e59eebea
MD5 3bd6a0386283547bfe3afeaa11ccf0cb
BLAKE2b-256 587f16ce85df0b3e81daab5e5c0b06bf073dc7d062dc8124c6b83cdeb50dbe84

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.9.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a12994a3acea0b239d16d7fc6c7dde5a51986727d7b651c76bdd38cd3cdfd1f1
MD5 b2c5b3ab14a806efbf65f013943a78be
BLAKE2b-256 df7573cce102616114c61b5266bbdb02f5d058729741a23ba2b76c0847430936

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.9.0-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 79536f97cd1e6c54f7b80c3a0386457dc136ee9ae6b84cf98824415449326d68
MD5 34499f32c58989e905bf1883a172641c
BLAKE2b-256 0e02e497cdb01634b5317ba63325bd67ac34664ecbdf066aac55d93069ac3a45

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pydantable-1.9.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.9.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 50ba98a2fc6d363c6902824fb4fc099b07b83f8f42563e671b4cdebdfa4688db
MD5 d9423f556eafcd50096891d9ccc0e5a0
BLAKE2b-256 2900882e8d27a4a159b5edc0b3d9b67574c16a4c6f3b3117db87e3974a7538f3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.9.0-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 75bf4952aa9175f5aea775e26f3268208ae3a59a9c97edbe91fc03b881fd694b
MD5 f208234ee93aca6776dd98aa41f1f263
BLAKE2b-256 94477cd181ca31346fc4b601c42ac7ffe2143c3a5205e99f63b32f85627348cd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.9.0-cp312-cp312-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 58a2d1032947c5f594064e2a11e644916a939cb2375fcf833824a631cd5b2957
MD5 d4bfa82b98cd5f6f4a255516b9ebabd0
BLAKE2b-256 8e15bcf8e1e5fdb4c4f37d9e44f73dfd8f46630f222e25dfdaaade484cd502d7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.9.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 59b86dabc17bc7d5bb77290c3ca6091ac5df535a9cec19e1c574ee575346b802
MD5 33dab81c33a19c0cd89b1aaa629a3256
BLAKE2b-256 d230928a989965392b343c9fab2cdd2b13eddf673b152066cf9f451a57a0deef

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.9.0-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 3a8b96f20145a62b4b19e0a5c0bac0e3eae4a42f18cb3fdfa34ace888890e572
MD5 0a4aba2e035c28c443a19e57adc4530e
BLAKE2b-256 4ec25c278f088d1581b1af0a97f6dd62f599293fb9eea2cd5fd8bfd53f5e5e74

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.9.0-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 e6ae8b78daaa5d090727892c7b856ece6b452d5727c78ab365dc2b38529416aa
MD5 c221597327e8563dc6a8dbeba925f382
BLAKE2b-256 2d22d1cf20b43528816ba8c3b2cf1c43c91190fc052d8c97b1891d20ad0ea0e2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.9.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ec2ea32ca7cb5c0affa29e58304bca6c726327db9e547f7172cbe9f607edeefd
MD5 f370188e5800fb724f3ef1ca15f23434
BLAKE2b-256 3d3849f8d0416b37c60f0fc985488e2c866028fd313a8ad2aa26b689cce833a2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.9.0-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 ac0ede9b24b6b1948cdb9851e25a72d56d0a8e3063cab97f37dc5969229b0df8
MD5 14d3fab600826021f7fb5df8ebedcbcb
BLAKE2b-256 4be6093b9f1949a9cd7fa6bc3212c95a7aa4c858b2385c207805d62b3104bc9a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-1.9.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 44273405bb8a15dcb7a711593f8c965dc8e8765ef55f6ef5ab1b9a4e5e7b255b
MD5 47ca6e8cc5454a9017b0f752b870a2ad
BLAKE2b-256 3f2ffd8df7c7e59cdebf864e59598b268eff2e05b74001e345cb087aa1bb58fb

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