DataFrame.online.unnest¶
- DataFrameOnlineNamespace.unnest(specs: Iterable[dict[str, Any]] | ModelBank | str | PathLike[str], *, separator: str | None = None) DataFrame[source]¶
Turn each spec’s output column in a frame into one column per field.
It is
LazyFrameOnlineNamespace.unnest()for a frame in memory, run at once.Parameters
specs,separatorAs
LazyFrameOnlineNamespace.unnest()takes them: the specs whose output columns to unnest, and a text to name each column after its spec too, as{spec}{separator}{name}, as Polars 2.0’sDataFrame.unnest(separator=)names a struct’s fields.
Returns
The frame with each output column replaced by its fields: each scalar field under its own name, and each
coeflist as one named column per coefficient, asLazyFrameOnlineNamespace.unnest()lists them.Raises
What
LazyFrameOnlineNamespace.unnest()raises, on the call.Examples
This code reads
dffrom Example data:spec = po.spec.ewridge("ridge", targets=["y"], features=["x0", "x1"], half_life=100.0) flat = df.online.fit_predict([spec]).online.unnest([spec]) print(flat.select("^coef_.*$").columns)
['coef_y_intercept', 'coef_y_x0', 'coef_y_x1']
See also
polars_online.spec.coef_fields(), each coefficient’s column name and where it sits incoef.polars_online.unnest(), this method as a function a type checker can see.