datatable.FExpr

FExpr is an object that encapsulates computations to be done on a frame.

FExpr objects are rarely constructed directly (though it is possible too), instead they are more commonly created as inputs/outputs from various functions in datatable.

Consider the following example:

math.sin(2 * f.Angle)

Here accessing column “Angle” in namespace f creates an FExpr. Multiplying this FExpr by a python scalar 2 creates a new FExpr. And finally, applying the sine function creates yet another FExpr. The resulting expression can be applied to a frame via the DT[i,j] method, which will compute that expression using the data of that particular frame.

Thus, an FExpr is a stored computation, which can later be applied to a Frame, or to multiple frames.

Because of its delayed nature, an FExpr checks its correctness at the time when it is applied to a frame, not sooner. In particular, it is possible for the same expression to work with one frame, but fail with another. In the example above, the expression may raise an error if there is no column named “Angle” in the frame, or if the column exists but has non-numeric type.

Most functions in datatable that accept an FExpr as an input, return a new FExpr as an output, thus creating a tree of FExprs as the resulting evaluation graph.

Also, all functions that accept FExprs as arguments, will also accept certain other python types as an input, essentially converting them into FExprs. Thus, we will sometimes say that a function accepts FExpr-like objects as arguments.

All binary operators op(x, y) listed below work when either x or y, or both are FExprs.

Construction

.__init__(e)

Create an FExpr.

.extend()

Append another FExpr.

.remove()

Remove columns from the FExpr.

Arithmeritc operators

__add__(x, y)

Addition x + y.

__sub__(x,  y)

Subtraction x - y.

__mul__(x, y)

Multiplication x * y.

__truediv__(x, y)

Division x / y.

__floordiv__(x, y)

Integer division x // y.

__mod__(x, y)

Modulus x % y (the remainder after integer division).

__pow__(x, y)

Power x ** y.

__pos__(x)

Unary plus +x.

__neg__(x)

Unary minus -x.

Bitwise operators

__and__(x, y)

Bitwise AND x & y.

__or__(x, y)

Bitwise OR x | y.

__xor__(x, y)

Bitwise XOR x ^ y.

__invert__(x)

Bitwise NOT ~x.

__lshift__(x, y)

Left shift x << y.

__rshift__(x, y)

Right shift x >> y.

Relational operators

__eq__(x, y)

Equal x == y.

__ne__(x, y)

Not equal x != y.

__lt__(x, y)

Less than x < y.

__le__(x, y)

Less than or equal x <= y.

__gt__(x, y)

Greater than x > y.

__ge__(x, y)

Greater than or equal x >= y.

Miscellaneous

.__bool__()

Implicitly convert FExpr into a boolean value.

.__repr__()

Used by Python function repr().

.len()

String length.

.re_match(pattern)

Check whether the string column matches a pattern.