polars_online.ColumnNotFoundError

class polars_online.ColumnNotFoundError[source]

Bases: ColumnNotFoundError, ValueError

The error raised when a column a call reads is not in its input.

For a column a spec reads, its message names the spec, the role the column plays (target, feature, clock, session, weight, group or label) and the column, and lists the input’s columns. po.stream.embargo, po.stream.refresh_time and po.gbdt raise it too, for a column they name. po.stream.with_windows raises a plain ValueError instead. po.eval raises it for a missing group, clock or weight column, and for a target column when spec is the spec dict; a plain ValueError when spec is the spec’s name alone.

po.ColumnNotFoundError is a subclass of Polars’ ColumnNotFoundError, which Polars raises for a column a query names that its input does not have, and of ValueError, the class of every other value the bank refuses. So either except catches it.

Examples

This code reads df from Example data:

spec = po.spec.ewridge("ridge", targets=["y"], features=["x0", "x1"], half_life=100.0)
bank = po.ModelBank([spec])
try:
    bank.fit_predict(df.drop("x1"))
except pl.exceptions.ColumnNotFoundError as e:   # or po.ColumnNotFoundError, or ValueError
    print(type(e).__name__, str(e).split(",")[0])
ColumnNotFoundError spec "ridge": feature column "x1" is not in the input

See also