skrub.Expr.skb.preview#

Expr.skb.preview()[source]#

Get the value computed for previews (shown when printing the expression).

Returns:
preview result

The result of evaluating the expression on the data stored in its variables.

See also

Expr.skb.subsample

Specify how to subsample an intermediate result when computing previews.

Expr.skb.eval

Evaluate the expression. Unlike preview, we can pass new data rather than using the values that variables were initialized with, but results are not cached, and no subsampling takes place by default.

Examples

>>> import skrub
>>> a = skrub.var('a', 1)
>>> b = skrub.var('b', 2)
>>> c = a + b

When we display an expression, we see a preview of the result (3 in this case):

>>> c
<BinOp: add>
Result:
―――――――
3

If we want to actually access that value 3, rather than just seeing it displayed, we can use .skb.preview():

>>> c.skb.preview()
3

This is the actual number 3, not an expression or just a display

>>> type(c.skb.preview())
<class 'int'>

Accessing the preview is usually faster than calling .skb.eval() because results are cached and subsampling is used by default.