Schemas
Schema
data_joinery.Schema
Define DataFrame fields from a dataclass or Pydantic model.
| PARAMETER | DESCRIPTION |
|---|---|
model
|
Class whose fields define the schema.
TYPE:
|
| ATTRIBUTE | DESCRIPTION |
|---|---|
model |
Class used to define the schema.
|
model_schema |
Parsed fields from the model.
|
Source code in src/data_joinery/schemas/schema.py
native_schema
Return this schema in a backend's native schema type.
| PARAMETER | DESCRIPTION |
|---|---|
schema_type
|
Native schema class to create, such as a Spark
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
NativeSchemaT
|
The compiled native schema. |
Source code in src/data_joinery/schemas/schema.py
create_dataframe
Create a DataFrame from model instances.
| PARAMETER | DESCRIPTION |
|---|---|
rows
|
Model instances to include in the DataFrame.
TYPE:
|
frame_type
|
DataFrame class to create.
TYPE:
|
**kwargs
|
Extra options passed to the DataFrame backend.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
FrameT
|
A DataFrame of the requested type. |
Source code in src/data_joinery/schemas/schema.py
coerce_dataframe
Validate and adapt a DataFrame to this schema.
strict rejects extra fields and type mismatches. Use
project_top_level to remove extra top-level fields, project
to remove extra nested fields, or project_cast to also cast field types.
Missing fields cause an error in every mode.
| PARAMETER | DESCRIPTION |
|---|---|
dataframe
|
DataFrame to validate and adapt.
TYPE:
|
mode
|
Schema coercion mode. Defaults to
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
FrameT
|
A DataFrame of the same backend type. |
| RAISES | DESCRIPTION |
|---|---|
SchemaCoercionError
|
If the DataFrame cannot match the schema. |