rheon.ArrowStruct¶
- class rheon.ArrowStruct¶
Bases:
objectOne spec’s output column, as an Arrow struct array a consumer reads once.
Use it to read a bank’s output without Polars, from
ModelBank.fit_predict_arrowandModelBank.predict_arrow, which return one per spec. For the output as Polars columns, useModelBank.fit_predictandModelBank.predict.Warning
The Arrow output is unstable: it may change in any release without that counting as a breaking change. Its input still arrives as a Polars frame, since the path that would take Arrow in is not built, so the pair is not yet in its final form. Under
RHEON_WARN_UNSTABLE=1, the calls that return one issuerheon.UnstableWarning.Examples
This code reads
dffrom Example data:spec = rp.spec.ewridge("ridge", targets=["y"], features=["x0", "x1"], half_life=100.0) bank = rp.ModelBank([spec]) (struct,) = bank.fit_predict_arrow(df) # one ArrowStruct per spec column = pl.Series(struct.name, struct) # read once, through __arrow_c_array__ print(struct.name, column.len())
ridge 400
See also
ModelBank.fit_predict_arrowandModelBank.predict_arrow, which return it.
Notes
A consumer, such as
pl.Seriesor pyarrow’spa.array, calls__arrow_c_array__and takes ownership of the two C structures it returns. DuckDB reads only__arrow_c_stream__, so give itpl.Series(struct). Reading the array hands its buffers to the consumer, so a second read raisesValueErrorrather than hand out buffers already given away.- name¶
The spec this struct is the output of. The capsule carries the field name, but pl.Series(obj) does not read it, so the caller names the series itself.