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 transformations for FastAPI and Pydantic services, backed by a Rust execution core.

Current release: 0.14.0 · Python 3.10+


Documentation

The full manual lives on Read the Docs:

https://pydantable.readthedocs.io/en/latest/

That site is the supported entry point for concepts, contracts, API notes, and examples. The sections below point to the same pages so you can jump straight from GitHub.

Topic Read the Docs
Home / overview Documentation home
DataFrameModel contract (inputs, transforms, collisions, materialization) DataFrameModel (SQLModel-like)
Column types (scalars, structs, list[T], nullability, unsupported cases) Supported data types
FastAPI (routers, bodies, collect, responses) FastAPI integration
Execution model (collect, to_dict, to_polars, optional Python Polars, UI modules) Execution (Rust engine)
Semantics (nulls, joins, ordering, reshaping, windows — Polars-style contract) Interface contract
Roadmap (0.5.0–0.14.0 shipped, path to v1.0.0) Roadmap
Why not use Polars directly? Why not just use Polars?
Pandas-style imports (pydantable.pandas) Pandas UI
PySpark-style imports (pydantable.pyspark) PySpark UI
PySpark helpers & parity PySpark interface · PySpark API parity
Polars parity (scorecard, workflows, transformation roadmap) Parity scorecard · Polars-style workflows · Transformation parity roadmap
Contributors (build, test, benchmarks, releases) Developer guide
Plan / vision (architecture phasing) Plan document
Python API reference (autodoc) API reference

For copy-paste convenience, the site base URL is:

https://pydantable.readthedocs.io/en/latest/


What PydanTable does

PydanTable keeps Pydantic models as the source of truth for:

  • column types and nullability (Optional[T] / T | None)
  • typed expressions — invalid combinations fail when the expression is built (Rust AST), not only at runtime
  • schema evolution — chained transforms produce new model types with stable rules (e.g. with_columns name collisions)

The default API feels Polars-like; optional pydantable.pandas and pydantable.pyspark modules only change naming and imports — execution is always the native core. Details: Execution, Interface contract.

0.14.0 adds window orderBy(..., nulls_last=...) (NULLS FIRST/LAST), DtypeDriftWarning for trusted_mode='shape_only', validate_data deprecation (use trusted_mode; removal after 0.16.0), FastAPI TestClient docs/tests, extra Hypothesis coverage, and PySpark dayofmonth / lower / upper. 0.13.0 delivered stabilization docs, trusted PyArrow strict, framed-window benchmarks, and related trust-boundary guidance. See changelog and Roadmap.

Expression surface (current release, Rust-typed Expr):

  • Globals in select: global_sum, global_mean, global_count, global_min, global_max, and global_row_count() (row count / COUNT(*)). PySpark: F.count() with no argument for row count; F.count(F.col(...)) for non-null column count.
  • Windows: row_number, rank, dense_rank, window_sum, window_mean, window_min, window_max, lag, lead with Window.partitionBy(...).orderBy(..., nulls_last=...) / .spec(), plus framed windows (rowsBetween, rangeBetween) for supported operations.
  • Temporal: strptime, unix_timestamp, cast from strdate / datetime (Polars parsing; use strptime for fixed formats), dt_* parts, dt_nanosecond on datetime / time.
  • Maps / binary: map_len, map_get, map_contains_key, binary_len, including nested JSON-like map value dtypes with string keys.
  • Map utilities: map_keys(), map_values(), map_entries(), and map_from_entries() for per-row key/value extraction and reconstruction on dict[str, T] columns.

PySpark-named helpers live under pydantable.pyspark.sql.functions. Details: Supported types, Interface contract, CHANGELOG.


Install

pip install pydantable

Optional Python Polars (for to_polars() only):

pip install 'pydantable[polars]'

From a git checkout, the Rust extension must be built (e.g. with maturin):

pip install .

See Developer guide — local setup for maturin develop, release builds, and CI parity.


Quick start

from pydantable import DataFrameModel

class User(DataFrameModel):
    id: int
    age: int | None

df = User({"id": [1, 2], "age": [20, None]})
df2 = df.with_columns(age2=df.age * 2)
df3 = df2.select("id", "age2")
df4 = df3.filter(df3.age2 > 10)

print(df4.to_dict())

Example output:

{'age2': [40], 'id': [1]}
  • Materialization: collect() returns a list of Pydantic row models; to_dict() returns columnar dict[str, list].

  • Alternate UIs:

    from pydantable.pandas import DataFrameModel as PandasDataFrameModel
    from pydantable.pyspark import DataFrameModel as PySparkDataFrameModel
    from pydantable import DataFrameModel as DefaultDataFrameModel
    

More examples: FastAPI integration, Polars-style workflows.

Input quality policy (optional): constructors are strict by default, and can be switched to best-effort ingestion with ignore_errors=True plus on_validation_errors=... to receive failed rows (row_index, row, validation errors). See DataFrameModel docs.


Development

make check-full   # Ruff, mypy, Rust fmt/clippy/tests (see Makefile for `rust-test` env)
pytest -q         # or: pytest -n auto  with the [dev] extra

Rust + Python: see Developer guide (formatting, maturin, make rust-test for cargo test with the venv PYTHONPATH, benchmarks, contribution workflow).


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-0.14.0.tar.gz (135.2 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pydantable-0.14.0-cp313-cp313-win_arm64.whl (17.2 MB view details)

Uploaded CPython 3.13Windows ARM64

pydantable-0.14.0-cp313-cp313-macosx_11_0_arm64.whl (15.4 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pydantable-0.14.0-cp313-cp313-macosx_10_12_x86_64.whl (17.0 MB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

pydantable-0.14.0-cp312-cp312-win_amd64.whl (19.0 MB view details)

Uploaded CPython 3.12Windows x86-64

pydantable-0.14.0-cp312-cp312-musllinux_1_2_x86_64.whl (17.3 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

pydantable-0.14.0-cp312-cp312-musllinux_1_2_aarch64.whl (15.8 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ ARM64

pydantable-0.14.0-cp312-cp312-manylinux_2_28_aarch64.whl (15.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

pydantable-0.14.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (17.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

pydantable-0.14.0-cp312-cp312-macosx_11_0_arm64.whl (15.4 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pydantable-0.14.0-cp312-cp312-macosx_10_12_x86_64.whl (17.0 MB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

pydantable-0.14.0-cp311-cp311-macosx_11_0_arm64.whl (15.4 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pydantable-0.14.0-cp311-cp311-macosx_10_12_x86_64.whl (17.0 MB view details)

Uploaded CPython 3.11macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: pydantable-0.14.0.tar.gz
  • Upload date:
  • Size: 135.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.12.6

File hashes

Hashes for pydantable-0.14.0.tar.gz
Algorithm Hash digest
SHA256 891f3a625d3f0f0a46904e5fa59de8a435e542b07cec8a1b3bb65acc94e747cf
MD5 189e3ea05336b7560c922c2d1365e156
BLAKE2b-256 bdb1135548f0c9341b513a7707b115ece51848a30d6e5f4983864187d60d8ac2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-0.14.0-cp313-cp313-win_arm64.whl
Algorithm Hash digest
SHA256 09049d4ac893fcb5aca4881b3bb3a6aa02d9418d2605d7c818f7751bf26dda95
MD5 7c20eb4efac4ced0300f82a781260fec
BLAKE2b-256 95e48ca8bbdb83500db610a25c7bd31c939972bd78801d48d183a24a9ea5274f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-0.14.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7fc06ce25891f0ed1ae629557d8b94b4706909b3f83d9e595d39745c48ebebf4
MD5 9ed837fcac35ba6f3f79070bc02589a2
BLAKE2b-256 c2d1bcb9ff58960a0c327502bfd710a31b8de1f97a49ec973462a216c557687e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-0.14.0-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 7aba7ac5467c3a055b81e0c75610bd17c37d0130cad8b0f6451dd695d400a717
MD5 f7c4d85c9bb04f956e93eec60f062365
BLAKE2b-256 a6abc74ebd8c87720926a999c4936bcefccc61c272bdccf36437c5cf2e20354d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-0.14.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 a19cbc687b7539fec88976eaffd81211599bfa2ffd3fb5aace3ede18beb60ced
MD5 da143b991159e3c5f2c33c80fcef1c2a
BLAKE2b-256 3e422c57cbaaab1dfd8bd3f90b656f76b81acec3d194f627acb110ba62b35a3f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-0.14.0-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 9a13636f3ece250c1292e104f6d43b0a4ca46d841150ba3d32b4df871cbd68a2
MD5 fe6e0d2fd74f575642672b436179e5ff
BLAKE2b-256 60eb21cc1f589bedeb529564657217452a58245c0adb452b8a1befc478512515

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-0.14.0-cp312-cp312-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 1a977ba52f8856452194c8d7853948cae8ab30a847de8184847e2d907fe22610
MD5 007a218ed08f9db86421ba20fd4d7ceb
BLAKE2b-256 ea5ba3dc3815ffd914ebae1328d0332999badf8caaf7ab21104013ba7ef04fc9

See more details on using hashes here.

File details

Details for the file pydantable-0.14.0-cp312-cp312-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pydantable-0.14.0-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 4b5cb7a6c2d91348d1b51cf269812c65952f9cb5a717054d4a01fb87052d896b
MD5 e159465dd45f24e1589114877a71724e
BLAKE2b-256 2e0a17ea8a5d65ec72229bbb32f04efaff61a80728147b2baf7d3e61e4fad8c0

See more details on using hashes here.

File details

Details for the file pydantable-0.14.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pydantable-0.14.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1b1f1234e4458d69f1f3439d7fbad9d3f37a88be7cb3f62e51d638d3c9c275cc
MD5 38c1453c3bb2414015472770a44135b9
BLAKE2b-256 904381c19f5cf0874c7e82bdc44af9fccc2c2df6569a1d8239f8761e094bd4da

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-0.14.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5b8d2f918bba35adaabcb77a4f76f654f08f7214611efbf65a58cac54cbf4c4f
MD5 9d97a90388b195c43b44994a19ed8b4a
BLAKE2b-256 dda26418c85674e68851d9fe8e2b504a6efe8f3316c55d0d98fc30aae1798a06

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-0.14.0-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 acc88a928d7eadb4bb4f6ea7109c3b7cc7f2a031927a576621819eee86ceb0de
MD5 0d3d3965b9e113079cfbd06744a4c2cb
BLAKE2b-256 2f1506d0bca934d5f6d577d328a04be3f3ab6f63cbc3438f12492a4b48e44ecc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-0.14.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 359b73271321df8683933e6d0d44946585e0369365172a0445cb8fe02f306288
MD5 632490885965f75678a814bfac40d667
BLAKE2b-256 12f207c067293caef9d031d0b64558e910a781eaefb14794cd07b5d043beddc7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantable-0.14.0-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 4bb63a3daf1ede93f06922a21d43a6c72ec132e675a87d3ebe406297146856da
MD5 f5c2ee9da6d91be4b21a048b1161ec5d
BLAKE2b-256 5f25bf7ecfa51c7e6c8747b997beef2f660b5b7602c94421dd8ab90d19b236ab

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