API Reference#
- class pandera_catalog.CatalogViewReader(catalog)[source]#
Query generated SQL views from a catalog backend.
- class pandera_catalog.PanderaCatalog(*, backend=None)[source]#
A registry for Pandera schemas.
Schemas are stored in memory by name. A future version will persist entries to a SQLAlchemy-backed database (SQLite by default).
Examples
>>> from pandera_catalog import PanderaCatalog >>> import pandera.pandas as pa >>> catalog = PanderaCatalog() >>> schema = pa.DataFrameSchema({"value": pa.Column(float)}) >>> catalog.register("my_schema", schema) >>> catalog.get("my_schema") <Schema DataFrameSchema(columns={'value': ...}, ...)>
- property backend: SqlCatalogBackend | None#
Return the configured SQL backend, if any.
- export_projection(name)[source]#
Materialise and return the schema defined by projection name.
- Return type:
DataFrameSchema
- get(name)[source]#
Return the schema registered under name.
- Parameters:
name (
str) – Name of the schema to retrieve.- Return type:
pandera.DataFrameSchema
- Raises:
KeyError – If name is not registered.
- get_entry(name)[source]#
Return the full
SchemaEntryfor name.- Parameters:
name (
str) – Name of the schema entry to retrieve.- Return type:
- Raises:
KeyError – If name is not registered.
- get_projection_entry(name)[source]#
Return the full projection entry registered under name.
- Return type:
- list_projections()[source]#
Return a sorted list of all registered projection names.
- Return type:
list[str]
- register(name, schema, *, description=None, tags=None, overwrite=False)[source]#
Register a Pandera schema under name.
- Parameters:
name (
str) – Unique identifier for the schema within this catalog.schema (
DataFrameSchema) – Apandera.DataFrameSchemainstance.description (
str|None) – Optional human-readable description of the schema.tags (
list[str] |None) – Optional list of string tags for categorisation.overwrite (
bool) – WhenTrue, silently replace any existing entry with the same name. WhenFalse(default), raiseKeyErrorif the name is already registered.
- Raises:
KeyError – If name is already registered and overwrite is
False.- Return type:
None
- register_projection(name, steps, *, description=None, overwrite=False)[source]#
Register a named projection from ordered step definitions.
- Parameters:
name (
str) – Unique projection name within this catalog.steps (
list[SchemaProjectionStep|Mapping[str,object]]) – Ordered list of projection steps. Each step must includeschema,kind, andnames.description (
str|None) – Optional human-readable description of the projection.overwrite (
bool) – WhenTrue, replace any existing projection with the same name.
- Raises:
KeyError – If any step schema is not registered, or if name already exists and overwrite is
False.ValueError – If steps are invalid, include duplicates, include unknown columns, or include an unknown step kind.
NotImplementedError – If a
kind: groupstep is provided.
- Return type:
None
- class pandera_catalog.SchemaEntry(name, schema, description=None, tags=<factory>)[source]#
A catalog entry wrapping a Pandera schema with metadata.
- name#
Unique name of the schema within the catalog.
- schema#
The Pandera
DataFrameSchemainstance.
- description#
Optional human-readable description.
- tags#
Optional list of string tags for categorisation or filtering.
- class pandera_catalog.SchemaProjectionEntry(name, steps, description=None)[source]#
A named projection built from ordered schema selection steps.
- class pandera_catalog.SchemaProjectionStep(schema, kind, names)[source]#
A single schema projection step.
- class pandera_catalog.SqlCatalogBackend(engine=None, url=None)[source]#
Persist catalog schemas/projections and maintain tabular views.
- load_projections()[source]#
Return persisted projection entries.
- Return type:
list[SchemaProjectionEntry]
- load_schemas()[source]#
Return persisted schema entries.
- Return type:
list[SchemaEntry]
- remove_projection(projection_name)[source]#
Delete a persisted projection and materialized rows.
- Return type:
None
- remove_schema(schema_name)[source]#
Delete a persisted schema and its flattened rows.
- Return type:
None
- pandera_catalog.load_schema_from_yaml(path)[source]#
Load a Pandera
DataFrameSchemafrom a YAML file.The YAML file must follow the format produced by
pandera.DataFrameSchema.to_yaml().- Parameters:
path (
Union[str,Path]) – Path to the.yaml(or.yml) schema definition file.- Return type:
pandera.DataFrameSchema
- Raises:
FileNotFoundError – If the file does not exist.
ValueError – If the file cannot be parsed as a Pandera schema.
Examples
>>> from pathlib import Path >>> from pandera_catalog.schemas import load_schema_from_yaml >>> schema = load_schema_from_yaml(Path("schemas/my_schema.yaml"))