Expressions#

daft.expressions.Expression

Expression Constructors#

daft.DataFrame.__getitem__

Gets a column from the DataFrame as an Expression (df["mycol"])

daft.expressions.col

Creates an Expression referring to the column with the provided name

daft.expressions.lit

Creates an Expression representing a column with every value set to the provided value

Operators#

Numeric#

Operations on numbers (floats and integers)

daft.expressions.Expression.__abs__()

Absolute of a numeric expression (abs(expr))

daft.expressions.Expression.__add__(other)

Adds two numeric expressions or concatenates two string expressions (e1 + e2)

daft.expressions.Expression.__sub__(other)

Subtracts two numeric expressions (e1 - e2)

daft.expressions.Expression.__mul__(other)

Multiplies two numeric expressions (e1 * e2)

daft.expressions.Expression.__truediv__(other)

True divides two numeric expressions (e1 / e2)

daft.expressions.Expression.__mod__(other)

Takes the mod of two numeric expressions (e1 % e2)

Logical#

Operations on logical expressions (True/False booleans)

daft.expressions.Expression.__invert__()

Inverts a boolean expression (~e)

daft.expressions.Expression.__and__(other)

Takes the logical AND of two boolean expressions (e1 & e2)

daft.expressions.Expression.__or__(other)

Takes the logical OR of two boolean expressions (e1 | e2)

daft.expressions.Expression.if_else(if_true, ...)

Conditionally choose values between two expressions using the current boolean expression as a condition

Comparisons#

Comparing expressions and values, returning a logical expression

daft.expressions.Expression.__lt__(other)

Compares if an expression is less than another (e1 < e2)

daft.expressions.Expression.__le__(other)

Compares if an expression is less than or equal to another (e1 <= e2)

daft.expressions.Expression.__eq__(other)

Compares if an expression is equal to another (e1 == e2)

daft.expressions.Expression.__ne__(other)

Compares if an expression is not equal to another (e1 != e2)

daft.expressions.Expression.__gt__(other)

Compares if an expression is greater than another (e1 > e2)

daft.expressions.Expression.__ge__(other)

Compares if an expression is greater than or equal to another (e1 >= e2)

daft.expressions.Expression.is_null()

Checks if values in the Expression are Null (a special value indicating missing data)

Floats#

Operations on strings, accessible through the Expression.float method accessor.

Example: e1.float.is_nan()

daft.expressions.expressions.ExpressionFloatNamespace.is_nan()

Checks if values are NaN (a special float value indicating not-a-number)

Strings#

Operations on strings, accessible through the Expression.str method accessor.

Example: e1.str.concat(e2)

daft.expressions.expressions.ExpressionStringNamespace.concat(other)

Concatenates two string expressions together

daft.expressions.expressions.ExpressionStringNamespace.contains(substr)

Checks whether each string contains the given pattern in a string column

daft.expressions.expressions.ExpressionStringNamespace.endswith(suffix)

Checks whether each string ends with the given pattern in a string column

daft.expressions.expressions.ExpressionStringNamespace.startswith(prefix)

Checks whether each string starts with the given pattern in a string column

daft.expressions.expressions.ExpressionStringNamespace.length()

Retrieves the length for a UTF-8 string column

Dates#

Operations on datetimes, accessible through the Expression.dt method accessor:

Example: e.dt.day()

daft.expressions.expressions.ExpressionDatetimeNamespace.day

Retrieves the day for a datetime column

daft.expressions.expressions.ExpressionDatetimeNamespace.month

Retrieves the month for a datetime column

daft.expressions.expressions.ExpressionDatetimeNamespace.year

Retrieves the year for a datetime column

daft.expressions.expressions.ExpressionDatetimeNamespace.day_of_week

Retrieves the day of the week for a datetime column, starting at 0 for Monday and ending at 6 for Sunday

URLs#

Operations on URLs, accessible through the Expression.url method accessor:

Example: e.url.download()

daft.expressions.expressions.ExpressionUrlNamespace.download

Treats each string as a URL, and downloads the bytes contents as a bytes column

Images#

Operations on images, accessible through the Expression.image method accessor:

Example: e.image.resize()

daft.expressions.expressions.ExpressionImageNamespace.resize

daft.expressions.expressions.ExpressionImageNamespace.decode

Changing Column Names/Types#

daft.expressions.Expression.alias

Gives the expression a new name, which is its column's name in the DataFrame schema and the name by which subsequent expressions can refer to the results of this expression.

daft.expressions.Expression.cast

Casts an expression to the given datatype if possible

Running Python Functions#

daft.expressions.Expression.apply

Apply a function on each value in a given expression