Contracts
Use these helpers in Annotated DataFrame parameters and return types to
choose how a transform checks a schema. Each helper takes a dataclass or
Pydantic model.
data_joinery.contract.Strict
Require the DataFrame to have exactly the model's fields and types.
Field order and nullability are ignored.
| PARAMETER | DESCRIPTION |
|---|---|
schema
|
Dataclass or Pydantic model that defines the expected fields.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
DataFrameContract
|
A DataFrame contract for use in a transform annotation. |
Source code in src/data_joinery/contract.py
data_joinery.contract.ProjectTopLevel
Keep the model's top-level columns and validate nested fields.
| PARAMETER | DESCRIPTION |
|---|---|
schema
|
Dataclass or Pydantic model that defines the expected fields.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
DataFrameContract
|
A DataFrame contract for use in a transform annotation. |
Source code in src/data_joinery/contract.py
data_joinery.contract.Project
Keep the model's fields, including fields in nested structs.
| PARAMETER | DESCRIPTION |
|---|---|
schema
|
Dataclass or Pydantic model that defines the expected fields.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
DataFrameContract
|
A DataFrame contract for use in a transform annotation. |
Source code in src/data_joinery/contract.py
data_joinery.contract.ProjectCast
Project columns and cast their values to the model's field types.
| PARAMETER | DESCRIPTION |
|---|---|
schema
|
Dataclass or Pydantic model that defines the expected fields.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
DataFrameContract
|
A DataFrame contract for use in a transform annotation. |
Source code in src/data_joinery/contract.py
Strict is also the default mode for Schema.coerce_dataframe().
No output
data_joinery.contract.VoidContract
dataclass
Contract for transforms that do not produce an output.