Skip to content

innovate.ingest_polars

All current Python definitions

View source · Source file SHA-256: 522871fe0b61b840b5f85b8f278beb2b79c7afd68645265ae3a68983d56d74e4

def ingest_polars(
frame: pl.DataFrame | pl.LazyFrame,
kind: str,
*,
provenance: dict[str, Any],
unit: str | None = None,
directed: bool = False,
) -> dict[str, Any]: ...

Convert a Polars table into a native validated dataset artifact.

Required columns depend on kind: adoption uses time and adoption with optional denominator; substitution uses time and columns beginning with share; competition uses time, value, unit_id and product_id; policy timing uses event_times and event_effects with optional event_labels; network edges use source and target with optional weight. Other columns are not included in the artifact.

  • frame: Polars DataFrame or LazyFrame. Lazy input is collected; numeric columns are cast to Float64 and identifier columns to String, then copied into JSON-compatible arrays for native validation.
  • kind: "adoption", "substitution", "competition", "policy_timing" or "network_edges".
  • provenance: Native schema-1.0 provenance mapping, including explicit source, license, extraction time and transformation information. The kernel validates it and computes or verifies the content checksum.
  • unit: Optional dataset unit label; omitted from the payload when None.
  • directed: Whether network edges are directed; defaults to False and has no effect on other dataset kinds.

Native ingestion result with the validated dataset and checksum evidence. Substitution share columns retain input order, with labels derived from their suffixes. The wrapper does not establish the truth of supplied provenance.

  • ValueError: If the kind is unsupported, required columns are missing, substitution has no share columns, or JSON values are non-finite.
  • NativeError: If dataset content or provenance violates the native contract.
  • TypeError: If provenance or data values are not JSON-compatible.
  • polars.exceptions.PolarsError: If collection, selection or casting fails.