Skip to main content

class  pixeltable.exprs.Expr

A Pixeltable expression. All Pixeltable expressions, including column references (such as t.col), UDF calls (t.my_string.lower()), and compound expressions (t.col + 5) are instances of this class. Not thread-safe: Expr and subclasses contain execution state and are never thread-safe. String formatting:
  • __format__() raises
  • motivation: user code such as f'Hello {t.name}' would otherwise produce one constant string for every row
  • to put an expression into a message, use {expr!s} or str(expr)

method  astype()

Signature
Return a new expression that casts this expression to a different type. Some casts also convert the value:
  • Bool to Int or Float: False and True become 0 and 1.
  • Int to Float.
  • String to Timestamp or Date: an ISO 8601 string is parsed, and a timestamp without a time zone is in the default time zone. For other formats, use timestamp.strptime() or date.strptime().
  • String to Image: the string is a file path or URL.
A Float does not cast to Int; use to_int() instead. Parameters:
  • new_type (ts.ColumnType | TypeForm): The type to cast to.
Examples: Given an existing column t.json_col of type pxt.Json, cast that column to type pxt.String:
This will assume that all values in t.json_col are actually strings, and it will result in an error at runtime if there are values in t.json_col that are not strings. It will not convert those values to a string representation. (For that, use the [dumps()][pixeltable.functions.json.dumps] UDF instead, and [loads()][pixeltable.functions.json.loads] to parse a JSON string.)

method  isin()

Signature
Return a new, boolean-valued expression that is True whenever this expression is in value_set. Parameters:
  • value_set (Any): Either another expression that evaluates to a set of values, or a constant collection of values. If the latter, can be any Iterable.
Examples: These examples assume that t is a table with a column int_col of type pxt.Int, and another column list_col of type pxt.Json, containing lists of integers. Select all rows where int_col is in the constant set {1, 3, 22}:
Select all rows where int_col is in the set of values in that row’s list_col:
Last modified on December 4, 2026