Skip to content

Expressions#

Daft Expressions allow you to express some computation that needs to happen in a DataFrame. This page provides an overview of all the functionality that is provided by Daft Expressions.

Constructors#

col #

col(name: str) -> Expression

Creates an Expression referring to the column with the provided name.

Parameters:

Name Type Description Default
name str

Name of column

required

Returns:

Name Type Description
Expression Expression

Expression representing the selected column

Examples:

1
2
3
4
>>> import daft
>>> df = daft.from_pydict({"x": [1, 2, 3], "y": [4, 5, 6]})
>>> df = df.select(daft.col("x"))
>>> df.show()
╭───────╮
│ x     │
│ ---   │
│ Int64 │
╞═══════╡
│ 1     │
├╌╌╌╌╌╌╌┤
│ 2     │
├╌╌╌╌╌╌╌┤
│ 3     │
╰───────╯
(Showing first 3 of 3 rows)
Source code in daft/expressions/expressions.py
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
def col(name: str) -> Expression:
    """Creates an Expression referring to the column with the provided name.

    Args:
        name: Name of column

    Returns:
        Expression: Expression representing the selected column

    Examples:
        >>> import daft
        >>> df = daft.from_pydict({"x": [1, 2, 3], "y": [4, 5, 6]})
        >>> df = df.select(daft.col("x"))
        >>> df.show()
        ╭───────╮
        │ x     │
        │ ---   │
        │ Int64 │
        ╞═══════╡
        │ 1     │
        ├╌╌╌╌╌╌╌┤
        │ 2     │
        ├╌╌╌╌╌╌╌┤
        │ 3     │
        ╰───────╯
        <BLANKLINE>
        (Showing first 3 of 3 rows)

    """
    return Expression._from_pyexpr(unresolved_col(name))

lit #

lit(value: object) -> Expression

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

Parameters:

Name Type Description Default
value object

value of the literal

required

Returns:

Name Type Description
Expression Expression

Expression representing the value provided

Examples:

1
2
3
4
>>> import daft
>>> df = daft.from_pydict({"x": [1, 2, 3]})
>>> df = df.with_column("y", daft.lit(1))
>>> df.show()
╭───────┬───────╮
│ x     ┆ y     │
│ ---   ┆ ---   │
│ Int64 ┆ Int64 │
╞═══════╪═══════╡
│ 1     ┆ 1     │
├╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
│ 2     ┆ 1     │
├╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
│ 3     ┆ 1     │
╰───────┴───────╯
(Showing first 3 of 3 rows)
Source code in daft/expressions/expressions.py
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
def lit(value: object) -> Expression:
    """Creates an Expression representing a column with every value set to the provided value.

    Args:
        value: value of the literal

    Returns:
        Expression: Expression representing the value provided

    Examples:
        >>> import daft
        >>> df = daft.from_pydict({"x": [1, 2, 3]})
        >>> df = df.with_column("y", daft.lit(1))
        >>> df.show()
        ╭───────┬───────╮
        │ x     ┆ y     │
        │ ---   ┆ ---   │
        │ Int64 ┆ Int64 │
        ╞═══════╪═══════╡
        │ 1     ┆ 1     │
        ├╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
        │ 2     ┆ 1     │
        ├╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
        │ 3     ┆ 1     │
        ╰───────┴───────╯
        <BLANKLINE>
        (Showing first 3 of 3 rows)

    """
    return Expression._from_pyexpr(_lit(value))

sql_expr #

sql_expr(sql: str) -> Expression

Parses a SQL string into a Daft Expression.

This function allows you to create Daft Expressions from SQL snippets, which can then be used in Daft operations or combined with other Daft Expressions.

Parameters:

Name Type Description Default
sql str

A SQL string to be parsed into a Daft Expression.

required

Returns:

Name Type Description
Expression Expression

A Daft Expression representing the parsed SQL.

Examples:

Create a simple SQL expression:

1
2
3
>>> import daft
>>> expr = daft.sql_expr("1 + 2")
>>> print(expr)
lit(1) + lit(2)

Use SQL expression in a Daft DataFrame operation:

1
2
3
>>> df = daft.from_pydict({"a": [1, 2, 3], "b": [4, 5, 6]})
>>> df = df.with_column("c", daft.sql_expr("a + b"))
>>> df.show()
╭───────┬───────┬───────╮
│ a     ┆ b     ┆ c     │
│ ---   ┆ ---   ┆ ---   │
│ Int64 ┆ Int64 ┆ Int64 │
╞═══════╪═══════╪═══════╡
│ 1     ┆ 4     ┆ 5     │
├╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
│ 2     ┆ 5     ┆ 7     │
├╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
│ 3     ┆ 6     ┆ 9     │
╰───────┴───────┴───────╯
(Showing first 3 of 3 rows)

daft.sql_expr is also called automatically for you in some DataFrame operations such as filters:

1
2
3
>>> df = daft.from_pydict({"x": [1, 2, 3], "y": [4, 5, 6]})
>>> result = df.where("x < 3 AND y > 4")
>>> result.show()
╭───────┬───────╮
│ x     ┆ y     │
│ ---   ┆ ---   │
│ Int64 ┆ Int64 │
╞═══════╪═══════╡
│ 2     ┆ 5     │
╰───────┴───────╯
(Showing first 1 of 1 rows)
Source code in daft/sql/sql.py
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
@PublicAPI
def sql_expr(sql: str) -> Expression:
    """Parses a SQL string into a Daft Expression.

    This function allows you to create Daft Expressions from SQL snippets, which can then be used
    in Daft operations or combined with other Daft Expressions.

    Args:
        sql (str): A SQL string to be parsed into a Daft Expression.

    Returns:
        Expression: A Daft Expression representing the parsed SQL.

    Examples:
        Create a simple SQL expression:

        >>> import daft
        >>> expr = daft.sql_expr("1 + 2")
        >>> print(expr)
        lit(1) + lit(2)

        Use SQL expression in a Daft DataFrame operation:

        >>> df = daft.from_pydict({"a": [1, 2, 3], "b": [4, 5, 6]})
        >>> df = df.with_column("c", daft.sql_expr("a + b"))
        >>> df.show()
        ╭───────┬───────┬───────╮
        │ a     ┆ b     ┆ c     │
        │ ---   ┆ ---   ┆ ---   │
        │ Int64 ┆ Int64 ┆ Int64 │
        ╞═══════╪═══════╪═══════╡
        │ 1     ┆ 4     ┆ 5     │
        ├╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
        │ 2     ┆ 5     ┆ 7     │
        ├╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
        │ 3     ┆ 6     ┆ 9     │
        ╰───────┴───────┴───────╯
        <BLANKLINE>
        (Showing first 3 of 3 rows)

        `daft.sql_expr` is also called automatically for you in some DataFrame operations such as filters:

        >>> df = daft.from_pydict({"x": [1, 2, 3], "y": [4, 5, 6]})
        >>> result = df.where("x < 3 AND y > 4")
        >>> result.show()
        ╭───────┬───────╮
        │ x     ┆ y     │
        │ ---   ┆ ---   │
        │ Int64 ┆ Int64 │
        ╞═══════╪═══════╡
        │ 2     ┆ 5     │
        ╰───────┴───────╯
        <BLANKLINE>
        (Showing first 1 of 1 rows)
    """
    return Expression._from_pyexpr(_sql_expr(sql))

Expression #

Expression()

Methods:

Name Description
__abs__

Absolute of a numeric expression.

__add__

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

__and__

Takes the logical AND of two boolean expressions, or bitwise AND of two integer expressions (e1 & e2).

__bool__
__eq__

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

__floordiv__

Floor divides two numeric expressions (e1 / e2).

__ge__

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

__getitem__

Syntactic sugar for daft.functions.get for string and int, and daft.functions.slice for slice.

__gt__

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

__hash__
__invert__

Inverts a boolean expression (~e).

__le__

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

__lshift__

Shifts the bits of an integer expression to the left (e1 << e2).

__lt__

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

__mod__

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

__mul__

Multiplies two numeric expressions (e1 * e2).

__ne__

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

__or__

Takes the logical OR of two boolean or integer expressions, or bitwise OR of two integer expressions (e1 | e2).

__radd__
__rand__

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

__reduce__
__repr__
__rfloordiv__

Reverse floor divides two numeric expressions (e2 / e1).

__rmod__

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

__rmul__
__ror__

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

__rshift__

Shifts the bits of an integer expression to the right (e1 >> e2).

__rsub__
__rtruediv__
__sub__

Subtracts two numeric expressions (e1 - e2).

__truediv__

True divides two numeric expressions (e1 / e2).

__xor__

Takes the logical XOR of two boolean or integer expressions, or bitwise XOR of two integer expressions (e1 ^ e2).

abs

Absolute of a numeric expression.

alias

Gives the expression a new name.

any_value

Returns any value in the expression.

apply

Apply a function on each value in a given expression.

approx_count_distinct

Calculates the approximate number of non-NULL distinct values in the expression.

approx_percentiles

Calculates the approximate percentile(s) for a column of numeric values.

arccos

The elementwise arc cosine of a numeric expression.

arccosh

The elementwise inverse hyperbolic cosine of a numeric expression.

arcsin

The elementwise arc sine of a numeric expression.

arcsinh

The elementwise inverse hyperbolic sine of a numeric expression.

arctan

The elementwise arc tangent of a numeric expression.

arctan2

Calculates the four quadrant arctangent of coordinates (y, x), in radians.

arctanh

The elementwise inverse hyperbolic tangent of a numeric expression.

as_binary
as_bool
as_date
as_decimal128
as_duration
as_embedding
as_extension
as_file
as_fixed_size_binary
as_fixed_size_list
as_float32
as_float64
as_image
as_int16
as_int32
as_int64
as_int8
as_interval
as_list
as_map
as_null
as_py

Returns this literal expression as a python value, raises a ValueError if this is not a literal expression.

as_python
as_sparse_tensor
as_string
as_struct
as_tensor
as_time
as_timestamp
as_uint16
as_uint32
as_uint64
as_uint8
avg

Alias for Expression.mean(). Check Expression.mean for more details.

between

Checks if values in the Expression are between lower and upper, inclusive.

bitwise_and

Bitwise AND of two integer expressions.

bitwise_or

Bitwise OR of two integer expressions.

bitwise_xor

Bitwise XOR of two integer expressions.

bool_and

Calculates the boolean AND of all values in a list.

bool_or

Calculates the boolean OR of all values in a list.

capitalize

Capitalize a UTF-8 string.

cast

Casts an expression to the given datatype if possible.

cbrt

The cube root of a numeric expression.

ceil

The ceiling of a numeric expression.

chunk

Splits each list into chunks of the given size.

clip

Clips an expression to the given minimum and maximum values.

coalesce

Returns the first non-null value among this expression and the provided expressions.

column_name
compress

Compress binary or string values using the specified codec.

concat

Concatenate two string expressions.

contains

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

convert_image

Convert an image expression to the specified mode.

convert_time_zone

Converts a timestamp to another timezone while preserving the instant in time.

cos

The elementwise cosine of a numeric expression.

cosh

The elementwise hyperbolic cosine of a numeric expression.

cosine_distance

Compute the cosine distance between two embeddings.

cosine_similarity

Compute the cosine similarity between two embeddings.

cot

The elementwise cotangent of a numeric expression.

count

Counts the number of values in the expression.

count_distinct

Counts the number of distinct values in the expression.

count_matches

Counts the number of times a pattern, or multiple patterns, appear in a string.

crop

Crops images with the provided bounding box.

csc

The elementwise cosecant of a numeric expression.

date

Retrieves the date for a datetime column.

date_trunc

Truncates the datetime column to the specified interval.

day

Retrieves the day for a datetime column.

day_of_month

Retrieves the day of the month for a datetime column.

day_of_week

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

day_of_year

Retrieves the ordinal day for a datetime column. Starting at 1 for January 1st and ending at 365 or 366 for December 31st.

decode

Decodes binary values using the specified character set.

decode_image

Decodes the binary data in this column into images.

decode_image_file

Decodes an image file into an Image column.

decompress

Decompress binary values using the specified codec.

degrees

The elementwise degrees of a numeric expression.

deserialize

Deserializes the expression (string) using the specified format and data type.

dot_product

Compute the dot product between two embeddings.

download

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

encode

Encode binary or string values using the specified character set.

encode_image

Encode an image column as the provided image file format, returning a binary column of encoded bytes.

endswith

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

eq_null_safe

Performs a null-safe equality comparison between two expressions.

euclidean_distance

Compute the Euclidean distance between two embeddings.

exp

The e^self of a numeric expression.

explode

Explode a list expression.

expm1

The e^self - 1 of a numeric expression.

file_path

Gets the path (URL) of a file as a string.

file_size

Gets the size of a file in bytes.

fill_nan

Fills NaN values in the Expression with the provided fill_value.

fill_null

Fills null values in the Expression with the provided fill_value.

find

Returns the index of the first occurrence of the substring in each string.

first_value

Returns the first value in the window frame.

floor

The floor of a numeric expression.

get

Get an index from a list expression or a field from a struct expression.

hamming_distance

Compute the bitwise Hamming distance between two hash fingerprints.

hamming_distance_str

Compute the character-level Hamming distance between two strings.

hash

Hashes the values in the Expression.

hour

Retrieves the hour for a datetime column.

ilike

Checks whether each string matches the given SQL ILIKE pattern, case insensitive.

image_attribute

Get a property of the image, such as 'width', 'height', 'channel', or 'mode'.

image_channel

Gets the number of channels in an image.

image_file_metadata

Gets metadata for an image file (width, height, format, mode).

image_hash

Computes a perceptual hash of an image.

image_height

Gets the height of an image in pixels.

image_mode

Gets the mode of an image as a string.

image_to_tensor

Convert an image expression to a tensor, inferring dtype and shape.

image_width

Gets the width of an image in pixels.

is_column
is_in

Checks if values in the Expression are in the provided iterable.

is_inf

Checks if values in the Expression are Infinity.

is_literal
is_nan

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

is_null

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

jaccard_similarity

Compute the Jaccard similarity between two embeddings.

jq

Applies a jq filter to the expression (string), returning the results as a string.

last_value

Returns the last value in the window frame.

left

Gets the n (from nchars) left-most characters of each string.

length

Retrieves the length of the given expression.

length_bytes

Retrieves the length for a UTF-8 string column in bytes.

like

Checks whether each string matches the given SQL LIKE pattern, case sensitive.

list_agg

Aggregates the values in the expression into a list.

list_agg_distinct

Aggregates the values in the expression into a list of distinct values (ignoring nulls).

list_append

Appends a value to each list in the column.

list_bool_and

Calculates the boolean AND of all values in a list.

list_bool_or

Calculates the boolean OR of all values in a list.

list_contains

Checks if each list contains the specified item.

list_count

Counts the number of elements in each list.

list_distinct

Returns a list of unique elements in each list, preserving order of first occurrence and ignoring nulls.

list_filter

Filters elements in the list using a boolean predicate over daft.element().

list_flatten

Flattens one level of nesting in each list.

list_join

Joins every element of a list using the specified string delimiter.

list_map

Evaluates an expression on all elements in the list.

list_max

Calculates the maximum of each list. If no non-null values in a list, the result is null.

list_mean

Calculates the mean of each list. If no non-null values in a list, the result is null.

list_min

Calculates the minimum of each list. If no non-null values in a list, the result is null.

list_sort

Sorts the inner lists of a list column.

list_sum

Sums each list. Empty lists and lists with all nulls yield null.

ln

The elementwise natural log of a numeric expression.

log

The elementwise log with given base, of a numeric expression.

log10

The elementwise log base 10 of a numeric expression.

log1p

The ln(self + 1) of a numeric expression.

log2

The elementwise log base 2 of a numeric expression.

lower

Convert UTF-8 string to all lowercase.

lpad

Left-pads each string by truncating or padding with the character.

lstrip

Strip whitespace from the left side of a UTF-8 string.

map_get

Retrieves the value for a key in a map column.

map_keys

Returns a list of all keys in the map.

max

Calculates the maximum value in the expression.

mean

Calculates the mean of the values in the expression.

median

Calculates the median of the values in the expression.

microsecond

Retrieves the microsecond for a datetime column.

millisecond

Retrieves the millisecond for a datetime column.

min

Calculates the minimum value in the expression.

minhash

Runs the MinHash algorithm on the series.

minute

Retrieves the minute for a datetime column.

month

Retrieves the month for a datetime column.

name
nanosecond

Retrieves the nanosecond for a datetime column.

negate

The negative of a numeric expression.

normalize

Normalizes a string for more useful deduplication.

not_nan

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

not_null

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

parse_url

Parse string URLs and extract URL components.

partition_days

Partitioning Transform that returns the number of days since epoch (1970-01-01).

partition_hours

Partitioning Transform that returns the number of hours since epoch (1970-01-01).

partition_iceberg_bucket

Partitioning Transform that returns the Hash Bucket following the Iceberg Specification of murmur3_32_x86.

partition_iceberg_truncate

Partitioning Transform that truncates the input to a standard width w following the Iceberg Specification.

partition_months

Partitioning Transform that returns the number of months since epoch (1970-01-01).

partition_years

Partitioning Transform that returns the number of years since epoch (1970-01-01).

pearson_correlation

Compute the Pearson correlation between two embeddings.

percentile

Calculates the exact percentile for a column of numeric values.

pow

The elementwise exponentiation of a numeric series.

power

The elementwise exponentiation of a numeric series.

product

Calculates the product of the values in the expression.

quarter

Retrieves the quarter for a datetime column.

radians

The elementwise radians of a numeric expression.

regexp

Check whether each string matches the given regular expression pattern in a string column.

regexp_count

Counts the number of times a regex pattern appears in a string.

regexp_extract

Extracts the specified match group from the first regex match in each string in a string column.

regexp_extract_all

Extracts the specified match group from all regex matches in each string in a string column.

regexp_replace

Replaces all occurrences of a regex pattern in a string column with a replacement string.

regexp_split

Splits each string on the given regex pattern, into a list of strings.

repeat

Repeats each string n times.

replace

Replaces all occurrences of a substring in a string with a replacement string.

replace_time_zone

Replaces the timezone of a timestamp while preserving the local time.

resize

Resize image into the provided width and height.

reverse

Reverse a UTF-8 string.

right

Gets the n (from nchars) right-most characters of each string.

round

The round of a numeric expression.

rpad

Right-pads each string by truncating or padding with the character.

rstrip

Strip whitespace from the right side of a UTF-8 string.

sec

The elementwise secant of a numeric expression.

second

Retrieves the second for a datetime column.

serialize

Serializes the expression as a string using the specified format.

shift_left

Shifts the bits of an integer expression to the left (expr << other).

shift_right

Shifts the bits of an integer expression to the right (expr >> other).

sign

The sign of a numeric expression.

simhash

Compute a SimHash fingerprint of this string expression.

sin

The elementwise sine of a numeric expression.

sinh

The elementwise hyperbolic sine of a numeric expression.

skew

Calculates the skewness of the values from the expression.

slice

Get a subset of each list or binary value.

split

Splits each string on the given string, into a list of strings.

sqrt

The square root of a numeric expression.

startswith

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

stddev

Calculates the standard deviation of the values in the expression.

strftime

Converts a datetime/date column to a string column.

string_agg

Aggregates the values in the expression into a single string by concatenating them.

strip

Strip whitespace from both sides of a UTF-8 string.

substr

Extract a substring from a string, starting at a specified index and extending for a given length.

sum

Calculates the sum of the values in the expression.

tan

The elementwise tangent of a numeric expression.

tanh

The elementwise hyperbolic tangent of a numeric expression.

time

Retrieves the time for a datetime column.

to_arrow_expr

Returns this expression as a pyarrow.compute.Expression for integrations with other systems.

to_camel_case

Convert a string to lower camel case.

to_date

Converts a string to a date using the specified format.

to_datetime

Converts a string to a datetime using the specified format and timezone.

to_kebab_case

Convert a string to kebab case.

to_snake_case

Convert a string to snake case.

to_title_case

Convert a string to title case.

to_unix_epoch

Converts a datetime column to a Unix timestamp with the specified time unit. (default: seconds).

to_upper_camel_case

Convert a string to upper camel case.

to_upper_kebab_case

Convert a string to upper kebab case.

to_upper_snake_case

Convert a string to upper snake case.

tokenize_decode

Decodes each list of integer tokens into a string using a tokenizer.

tokenize_encode

Encodes each string as a list of integer tokens using a tokenizer.

total_days

Calculates the total number of days for a duration column.

total_hours

Calculates the total number of hours for a duration column.

total_microseconds

Calculates the total number of microseconds for a duration column.

total_milliseconds

Calculates the total number of milliseconds for a duration column.

total_minutes

Calculates the total number of minutes for a duration column.

total_nanoseconds

Calculates the total number of nanoseconds for a duration column.

total_seconds

Calculates the total number of seconds for a duration column.

try_cast

Attempts to cast an expression to the given datatype, returning null on failure.

try_compress

Compress or null if unsuccessful.

try_decode

Decode or null if unsuccessful.

try_decompress

Decompress or null if unsuccessful.

try_deserialize

Deserializes the expression (string) using the specified format and data type, inserting nulls on failures.

try_encode

Encode or null if unsuccessful.

udf
unix_date

Retrieves the number of days since 1970-01-01 00:00:00 UTC.

unnest

Flatten the fields of a struct expression into columns in a DataFrame.

upload

Uploads a column of binary data to the provided location(s) (also supports S3, local etc).

upper

Convert UTF-8 string to all upper.

value_counts

Counts the occurrences of each distinct value in the list.

var

Calculates the variance of the values in the expression.

video_frames

Decodes video frames from a video file.

video_keyframes

Gets keyframes for a video file.

video_metadata

Gets metadata for a video file.

week_of_year

Retrieves the week of the year for a datetime column.

year

Retrieves the year for a datetime column.

Source code in daft/expressions/expressions.py
141
142
def __init__(self) -> None:
    raise NotImplementedError("We do not support creating a Expression via __init__ ")

__abs__ #

__abs__() -> Expression

Absolute of a numeric expression.

Source code in daft/expressions/expressions.py
222
223
224
def __abs__(self) -> Expression:
    """Absolute of a numeric expression."""
    return self.abs()

__add__ #

__add__(other: object) -> Expression

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

Source code in daft/expressions/expressions.py
236
237
238
239
def __add__(self, other: object) -> Expression:
    """Adds two numeric expressions or concatenates two string expressions (``e1 + e2``)."""
    expr = Expression._to_expression(other)
    return Expression._from_pyexpr(self._expr + expr._expr)

__and__ #

__and__(other: Expression) -> Expression

Takes the logical AND of two boolean expressions, or bitwise AND of two integer expressions (e1 & e2).

Source code in daft/expressions/expressions.py
282
283
284
285
def __and__(self, other: Expression) -> Expression:
    """Takes the logical AND of two boolean expressions, or bitwise AND of two integer expressions (``e1 & e2``)."""
    expr = Expression._to_expression(other)
    return Expression._from_pyexpr(self._expr & expr._expr)

__bool__ #

__bool__() -> bool
Source code in daft/expressions/expressions.py
216
217
218
219
220
def __bool__(self) -> bool:
    raise ValueError(
        "Expressions don't have a truth value. "
        "If you used Python keywords `and` `not` `or` on an expression, use `&` `~` `|` instead."
    )

__eq__ #

__eq__(other: Expression) -> Expression

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

Source code in daft/expressions/expressions.py
317
318
319
320
def __eq__(self, other: Expression) -> Expression:  # type: ignore
    """Compares if an expression is equal to another (``e1 == e2``)."""
    expr = Expression._to_expression(other)
    return Expression._from_pyexpr(self._expr == expr._expr)

__floordiv__ #

__floordiv__(other: Expression) -> Expression

Floor divides two numeric expressions (e1 / e2).

Source code in daft/expressions/expressions.py
375
376
377
378
def __floordiv__(self, other: Expression) -> Expression:
    """Floor divides two numeric expressions (``e1 / e2``)."""
    expr = Expression._to_expression(other)
    return Expression._from_pyexpr(self._expr // expr._expr)

__ge__ #

__ge__(other: Expression) -> Expression

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

Source code in daft/expressions/expressions.py
342
343
344
345
def __ge__(self, other: Expression) -> Expression:
    """Compares if an expression is greater than or equal to another (``e1 >= e2``)."""
    expr = Expression._to_expression(other)
    return Expression._from_pyexpr(self._expr >= expr._expr)

__getitem__ #

__getitem__(key: str | int | slice) -> Expression

Syntactic sugar for daft.functions.get for string and int, and daft.functions.slice for slice.

Examples:

Getting a single value:

1
2
3
4
>>> import daft
>>> df = daft.from_pydict({"struct": [{"x": 1, "y": 2}, {"x": 3, "y": 4}], "list": [[10, 20], [30, 40]]})
>>> df = df.select(df["struct"]["x"], df["list"][0].alias("first"))
>>> df.show()
╭───────┬───────╮
│ x     ┆ first │
│ ---   ┆ ---   │
│ Int64 ┆ Int64 │
╞═══════╪═══════╡
│ 1     ┆ 10    │
├╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
│ 3     ┆ 30    │
╰───────┴───────╯
(Showing first 2 of 2 rows)

Getting a slice:

1
2
3
>>> df = daft.from_pydict({"x": [[1, 2, 3], [4, 5, 6, 7], [8]]})
>>> df = df.select(df["x"][1:-1])
>>> df.show()
╭─────────────╮
│ x           │
│ ---         │
│ List[Int64] │
╞═════════════╡
│ [2]         │
├╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ [5, 6]      │
├╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ []          │
╰─────────────╯
(Showing first 3 of 3 rows)
See Also

daft.functions.get daft.functions.slice

Source code in daft/expressions/expressions.py
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
def __getitem__(self, key: builtins.str | int | slice) -> Expression:
    """Syntactic sugar for `daft.functions.get` for string and int, and `daft.functions.slice` for slice.

    Examples:
        Getting a single value:
        >>> import daft
        >>> df = daft.from_pydict({"struct": [{"x": 1, "y": 2}, {"x": 3, "y": 4}], "list": [[10, 20], [30, 40]]})
        >>> df = df.select(df["struct"]["x"], df["list"][0].alias("first"))
        >>> df.show()
        ╭───────┬───────╮
        │ x     ┆ first │
        │ ---   ┆ ---   │
        │ Int64 ┆ Int64 │
        ╞═══════╪═══════╡
        │ 1     ┆ 10    │
        ├╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
        │ 3     ┆ 30    │
        ╰───────┴───────╯
        <BLANKLINE>
        (Showing first 2 of 2 rows)

        Getting a slice:
        >>> df = daft.from_pydict({"x": [[1, 2, 3], [4, 5, 6, 7], [8]]})
        >>> df = df.select(df["x"][1:-1])
        >>> df.show()
        ╭─────────────╮
        │ x           │
        │ ---         │
        │ List[Int64] │
        ╞═════════════╡
        │ [2]         │
        ├╌╌╌╌╌╌╌╌╌╌╌╌╌┤
        │ [5, 6]      │
        ├╌╌╌╌╌╌╌╌╌╌╌╌╌┤
        │ []          │
        ╰─────────────╯
        <BLANKLINE>
        (Showing first 3 of 3 rows)

    Tip: See Also
        [`daft.functions.get`](https://docs.daft.ai/en/stable/api/functions/get/)
        [`daft.functions.slice`](https://docs.daft.ai/en/stable/api/functions/slice/)

    """
    if isinstance(key, builtins.slice):
        from daft.functions import slice

        if key.step is not None:
            raise ValueError(
                "`Expression.__getitem__` does not yet support slicing with step: `expr[start:stop:step]`"
            )

        start = key.start if key.start is not None else 0
        return slice(self, start, key.stop)
    else:
        from daft.functions import get

        return get(self, key)

__gt__ #

__gt__(other: Expression) -> Expression

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

Source code in daft/expressions/expressions.py
337
338
339
340
def __gt__(self, other: Expression) -> Expression:
    """Compares if an expression is greater than another (``e1 > e2``)."""
    expr = Expression._to_expression(other)
    return Expression._from_pyexpr(self._expr > expr._expr)

__hash__ #

__hash__() -> int
Source code in daft/expressions/expressions.py
1562
1563
def __hash__(self) -> int:
    return self._expr.__hash__()

__invert__ #

__invert__() -> Expression

Inverts a boolean expression (~e).

Source code in daft/expressions/expressions.py
370
371
372
373
def __invert__(self) -> Expression:
    """Inverts a boolean expression (``~e``)."""
    expr = self._expr.__invert__()
    return Expression._from_pyexpr(expr)

__le__ #

__le__(other: Expression) -> Expression

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

Source code in daft/expressions/expressions.py
312
313
314
315
def __le__(self, other: Expression) -> Expression:
    """Compares if an expression is less than or equal to another (``e1 <= e2``)."""
    expr = Expression._to_expression(other)
    return Expression._from_pyexpr(self._expr <= expr._expr)

__lshift__ #

__lshift__(other: Expression) -> Expression

Shifts the bits of an integer expression to the left (e1 << e2).

Parameters:

Name Type Description Default
other Expression

The number of bits to shift the expression to the left

required
Source code in daft/expressions/expressions.py
347
348
349
350
351
352
353
354
def __lshift__(self, other: Expression) -> Expression:
    """Shifts the bits of an integer expression to the left (``e1 << e2``).

    Args:
        other: The number of bits to shift the expression to the left
    """
    expr = Expression._to_expression(other)
    return Expression._from_pyexpr(self._expr << expr._expr)

__lt__ #

__lt__(other: Expression) -> Expression

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

Source code in daft/expressions/expressions.py
307
308
309
310
def __lt__(self, other: Expression) -> Expression:
    """Compares if an expression is less than another (``e1 < e2``)."""
    expr = Expression._to_expression(other)
    return Expression._from_pyexpr(self._expr < expr._expr)

__mod__ #

__mod__(other: Expression) -> Expression

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

Source code in daft/expressions/expressions.py
272
273
274
275
def __mod__(self, other: Expression) -> Expression:
    """Takes the mod of two numeric expressions (``e1 % e2``)."""
    expr = Expression._to_expression(other)
    return Expression._from_pyexpr(self._expr % expr._expr)

__mul__ #

__mul__(other: object) -> Expression

Multiplies two numeric expressions (e1 * e2).

Source code in daft/expressions/expressions.py
254
255
256
257
def __mul__(self, other: object) -> Expression:
    """Multiplies two numeric expressions (``e1 * e2``)."""
    expr = Expression._to_expression(other)
    return Expression._from_pyexpr(self._expr * expr._expr)

__ne__ #

__ne__(other: Expression) -> Expression

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

Source code in daft/expressions/expressions.py
332
333
334
335
def __ne__(self, other: Expression) -> Expression:  # type: ignore
    """Compares if an expression is not equal to another (``e1 != e2``)."""
    expr = Expression._to_expression(other)
    return Expression._from_pyexpr(self._expr != expr._expr)

__or__ #

__or__(other: Expression) -> Expression

Takes the logical OR of two boolean or integer expressions, or bitwise OR of two integer expressions (e1 | e2).

Source code in daft/expressions/expressions.py
292
293
294
295
def __or__(self, other: Expression) -> Expression:
    """Takes the logical OR of two boolean or integer expressions, or bitwise OR of two integer expressions (``e1 | e2``)."""
    expr = Expression._to_expression(other)
    return Expression._from_pyexpr(self._expr | expr._expr)

__radd__ #

__radd__(other: object) -> Expression
Source code in daft/expressions/expressions.py
241
242
243
def __radd__(self, other: object) -> Expression:
    expr = Expression._to_expression(other)
    return Expression._from_pyexpr(expr._expr + self._expr)

__rand__ #

__rand__(other: Expression) -> Expression

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

Source code in daft/expressions/expressions.py
287
288
289
290
def __rand__(self, other: Expression) -> Expression:
    """Takes the logical reverse AND of two boolean expressions (``e1 & e2``)."""
    expr = Expression._to_expression(other)
    return Expression._from_pyexpr(expr._expr & self._expr)

__reduce__ #

__reduce__() -> tuple[Callable[[PyExpr], Expression], tuple[PyExpr]]
Source code in daft/expressions/expressions.py
1565
1566
def __reduce__(self) -> tuple[Callable[[_PyExpr], Expression], tuple[_PyExpr]]:
    return Expression._from_pyexpr, (self._expr,)

__repr__ #

__repr__() -> str
Source code in daft/expressions/expressions.py
1553
1554
def __repr__(self) -> builtins.str:
    return repr(self._expr)

__rfloordiv__ #

__rfloordiv__(other: object) -> Expression

Reverse floor divides two numeric expressions (e2 / e1).

Source code in daft/expressions/expressions.py
380
381
382
383
def __rfloordiv__(self, other: object) -> Expression:
    """Reverse floor divides two numeric expressions (``e2 / e1``)."""
    expr = Expression._to_expression(other)
    return Expression._from_pyexpr(expr._expr // self._expr)

__rmod__ #

__rmod__(other: Expression) -> Expression

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

Source code in daft/expressions/expressions.py
277
278
279
280
def __rmod__(self, other: Expression) -> Expression:
    """Takes the mod of two numeric expressions (``e1 % e2``)."""
    expr = Expression._to_expression(other)
    return Expression._from_pyexpr(expr._expr % self._expr)

__rmul__ #

__rmul__(other: object) -> Expression
Source code in daft/expressions/expressions.py
259
260
261
def __rmul__(self, other: object) -> Expression:
    expr = Expression._to_expression(other)
    return Expression._from_pyexpr(expr._expr * self._expr)

__ror__ #

__ror__(other: Expression) -> Expression

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

Source code in daft/expressions/expressions.py
302
303
304
305
def __ror__(self, other: Expression) -> Expression:
    """Takes the logical reverse OR of two boolean expressions (``e1 | e2``)."""
    expr = Expression._to_expression(other)
    return Expression._from_pyexpr(expr._expr | self._expr)

__rshift__ #

__rshift__(other: Expression) -> Expression

Shifts the bits of an integer expression to the right (e1 >> e2).

.. NOTE::

1
2
For unsigned integers, this expression perform a logical right shift.
For signed integers, this expression perform an arithmetic right shift.

Parameters:

Name Type Description Default
other Expression

The number of bits to shift the expression to the right

required
Source code in daft/expressions/expressions.py
356
357
358
359
360
361
362
363
364
365
366
367
368
def __rshift__(self, other: Expression) -> Expression:
    """Shifts the bits of an integer expression to the right (``e1 >> e2``).

    .. NOTE::

        For unsigned integers, this expression perform a logical right shift.
        For signed integers, this expression perform an arithmetic right shift.

    Args:
        other: The number of bits to shift the expression to the right
    """
    expr = Expression._to_expression(other)
    return Expression._from_pyexpr(self._expr >> expr._expr)

__rsub__ #

__rsub__(other: object) -> Expression
Source code in daft/expressions/expressions.py
250
251
252
def __rsub__(self, other: object) -> Expression:
    expr = Expression._to_expression(other)
    return Expression._from_pyexpr(expr._expr - self._expr)

__rtruediv__ #

__rtruediv__(other: object) -> Expression
Source code in daft/expressions/expressions.py
268
269
270
def __rtruediv__(self, other: object) -> Expression:
    expr = Expression._to_expression(other)
    return Expression._from_pyexpr(expr._expr / self._expr)

__sub__ #

__sub__(other: object) -> Expression

Subtracts two numeric expressions (e1 - e2).

Source code in daft/expressions/expressions.py
245
246
247
248
def __sub__(self, other: object) -> Expression:
    """Subtracts two numeric expressions (``e1 - e2``)."""
    expr = Expression._to_expression(other)
    return Expression._from_pyexpr(self._expr - expr._expr)

__truediv__ #

__truediv__(other: object) -> Expression

True divides two numeric expressions (e1 / e2).

Source code in daft/expressions/expressions.py
263
264
265
266
def __truediv__(self, other: object) -> Expression:
    """True divides two numeric expressions (``e1 / e2``)."""
    expr = Expression._to_expression(other)
    return Expression._from_pyexpr(self._expr / expr._expr)

__xor__ #

__xor__(other: Expression) -> Expression

Takes the logical XOR of two boolean or integer expressions, or bitwise XOR of two integer expressions (e1 ^ e2).

Source code in daft/expressions/expressions.py
297
298
299
300
def __xor__(self, other: Expression) -> Expression:
    """Takes the logical XOR of two boolean or integer expressions, or bitwise XOR of two integer expressions (``e1 ^ e2``)."""
    expr = Expression._to_expression(other)
    return Expression._from_pyexpr(self._expr ^ expr._expr)

abs #

abs() -> Expression

Absolute of a numeric expression.

See Also

daft.functions.abs

Source code in daft/expressions/expressions.py
226
227
228
229
230
231
232
233
234
def abs(self) -> Expression:
    """Absolute of a numeric expression.

    Tip: See Also
        [`daft.functions.abs`](https://docs.daft.ai/en/stable/api/functions/abs/)
    """
    from daft.functions import abs

    return abs(self)

alias #

alias(name: str) -> Expression

Gives the expression a new name.

Parameters:

Name Type Description Default
name str

New name for expression

required

Returns:

Name Type Description
Expression Expression

Renamed expression

Examples:

1
2
3
4
>>> import daft
>>> df = daft.from_pydict({"x": [1, 2, 3]})
>>> df = df.select(col("x").alias("y"))
>>> df.show()
╭───────╮
│ y     │
│ ---   │
│ Int64 │
╞═══════╡
│ 1     │
├╌╌╌╌╌╌╌┤
│ 2     │
├╌╌╌╌╌╌╌┤
│ 3     │
╰───────╯
(Showing first 3 of 3 rows)
Source code in daft/expressions/expressions.py
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
def alias(self, name: builtins.str) -> Expression:
    """Gives the expression a new name.

    Args:
        name: New name for expression

    Returns:
        Expression: Renamed expression

    Examples:
        >>> import daft
        >>> df = daft.from_pydict({"x": [1, 2, 3]})
        >>> df = df.select(col("x").alias("y"))
        >>> df.show()
        ╭───────╮
        │ y     │
        │ ---   │
        │ Int64 │
        ╞═══════╡
        │ 1     │
        ├╌╌╌╌╌╌╌┤
        │ 2     │
        ├╌╌╌╌╌╌╌┤
        │ 3     │
        ╰───────╯
        <BLANKLINE>
        (Showing first 3 of 3 rows)

    """
    assert isinstance(name, str)
    expr = self._expr.alias(name)
    return Expression._from_pyexpr(expr)

any_value #

any_value(ignore_nulls: bool = False) -> Expression

Returns any value in the expression.

See Also

daft.functions.any_value

Source code in daft/expressions/expressions.py
1156
1157
1158
1159
1160
1161
1162
1163
1164
def any_value(self, ignore_nulls: bool = False) -> Expression:
    """Returns any value in the expression.

    Tip: See Also
        [`daft.functions.any_value`](https://docs.daft.ai/en/stable/api/functions/any_value/)
    """
    from daft.functions import any_value

    return any_value(self, ignore_nulls=ignore_nulls)

apply #

apply(func: Callable[..., Any], return_dtype: DataTypeLike) -> Expression

Apply a function on each value in a given expression.

Parameters:

Name Type Description Default
func Callable[..., Any]

Function to run per value of the expression

required
return_dtype DataTypeLike

Return datatype of the function that was ran

required

Returns:

Name Type Description
Expression Expression

New expression after having run the function on the expression

Note

This is just syntactic sugar on top of a UDF and is convenient to use when your function only operates on a single column, and does not benefit from executing on batches. For either of those other use-cases, use a UDF instead.

Examples:

1
2
3
4
5
6
7
8
>>> import daft
>>> df = daft.from_pydict({"x": ["1", "2", "tim"]})
>>> def f(x_val: str) -> int:
...     if x_val.isnumeric():
...         return int(x_val)
...     else:
...         return 0
>>> df.with_column("num_x", df["x"].apply(f, return_dtype=daft.DataType.int64())).collect()
╭────────┬───────╮
│ x      ┆ num_x │
│ ---    ┆ ---   │
│ String ┆ Int64 │
╞════════╪═══════╡
│ 1      ┆ 1     │
├╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
│ 2      ┆ 2     │
├╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
│ tim    ┆ 0     │
╰────────┴───────╯
(Showing first 3 of 3 rows)
Source code in daft/expressions/expressions.py
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
def apply(self, func: Callable[..., Any], return_dtype: DataTypeLike) -> Expression:
    """Apply a function on each value in a given expression.

    Args:
        func: Function to run per value of the expression
        return_dtype: Return datatype of the function that was ran

    Returns:
        Expression: New expression after having run the function on the expression

    Note:
        This is just syntactic sugar on top of a UDF and is convenient to use when your function only operates
        on a single column, and does not benefit from executing on batches. For either of those other use-cases,
        use a UDF instead.

    Examples:
        >>> import daft
        >>> df = daft.from_pydict({"x": ["1", "2", "tim"]})
        >>> def f(x_val: str) -> int:
        ...     if x_val.isnumeric():
        ...         return int(x_val)
        ...     else:
        ...         return 0
        >>> df.with_column("num_x", df["x"].apply(f, return_dtype=daft.DataType.int64())).collect()
        ╭────────┬───────╮
        │ x      ┆ num_x │
        │ ---    ┆ ---   │
        │ String ┆ Int64 │
        ╞════════╪═══════╡
        │ 1      ┆ 1     │
        ├╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
        │ 2      ┆ 2     │
        ├╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
        │ tim    ┆ 0     │
        ╰────────┴───────╯
        <BLANKLINE>
        (Showing first 3 of 3 rows)

    """
    from daft.udf import UDF

    inferred_return_dtype = DataType._infer(return_dtype)

    def batch_func(self_series: Series) -> list[Any]:
        return [func(x) for x in self_series]

    name = getattr(func, "__module__", "")
    if name:
        name = name + "."
    if hasattr(func, "__qualname__"):
        name = name + getattr(func, "__qualname__")
    elif hasattr(func, "__class__"):
        name = name + func.__class__.__name__
    else:
        name = name + func.__name__

    return UDF(
        inner=batch_func,
        name=name,
        return_dtype=inferred_return_dtype,
    )(self)

approx_count_distinct #

approx_count_distinct() -> Expression

Calculates the approximate number of non-NULL distinct values in the expression.

See Also

daft.functions.approx_count_distinct

Source code in daft/expressions/expressions.py
1030
1031
1032
1033
1034
1035
1036
1037
1038
def approx_count_distinct(self) -> Expression:
    """Calculates the approximate number of non-`NULL` distinct values in the expression.

    Tip: See Also
          [`daft.functions.approx_count_distinct`](https://docs.daft.ai/en/stable/api/functions/approx_count_distinct/)
    """
    from daft.functions import approx_count_distinct

    return approx_count_distinct(self)

approx_percentiles #

approx_percentiles(percentiles: float | list[float]) -> Expression

Calculates the approximate percentile(s) for a column of numeric values.

See Also

daft.functions.approx_percentiles

Source code in daft/expressions/expressions.py
1040
1041
1042
1043
1044
1045
1046
1047
1048
def approx_percentiles(self, percentiles: builtins.float | builtins.list[builtins.float]) -> Expression:
    """Calculates the approximate percentile(s) for a column of numeric values.

    Tip: See Also
        [`daft.functions.approx_percentiles`](https://docs.daft.ai/en/stable/api/functions/approx_percentiles/)
    """
    from daft.functions import approx_percentiles

    return approx_percentiles(self, percentiles)

arccos #

arccos() -> Expression

The elementwise arc cosine of a numeric expression.

See Also

daft.functions.arccos

Source code in daft/expressions/expressions.py
770
771
772
773
774
775
776
777
778
def arccos(self) -> Expression:
    """The elementwise arc cosine of a numeric expression.

    Tip: See Also
        [`daft.functions.arccos`](https://docs.daft.ai/en/stable/api/functions/arccos/)
    """
    from daft.functions import arccos

    return arccos(self)

arccosh #

arccosh() -> Expression

The elementwise inverse hyperbolic cosine of a numeric expression.

See Also

daft.functions.arccosh

Source code in daft/expressions/expressions.py
810
811
812
813
814
815
816
817
818
def arccosh(self) -> Expression:
    """The elementwise inverse hyperbolic cosine of a numeric expression.

    Tip: See Also
        [`daft.functions.arccosh`](https://docs.daft.ai/en/stable/api/functions/arccosh/)
    """
    from daft.functions import arccosh

    return arccosh(self)

arcsin #

arcsin() -> Expression

The elementwise arc sine of a numeric expression.

See Also

daft.functions.arcsin

Source code in daft/expressions/expressions.py
760
761
762
763
764
765
766
767
768
def arcsin(self) -> Expression:
    """The elementwise arc sine of a numeric expression.

    Tip: See Also
        [`daft.functions.arcsin`](https://docs.daft.ai/en/stable/api/functions/arcsin/)
    """
    from daft.functions import arcsin

    return arcsin(self)

arcsinh #

arcsinh() -> Expression

The elementwise inverse hyperbolic sine of a numeric expression.

See Also

daft.functions.arcsinh

Source code in daft/expressions/expressions.py
820
821
822
823
824
825
826
827
828
def arcsinh(self) -> Expression:
    """The elementwise inverse hyperbolic sine of a numeric expression.

    Tip: See Also
        [`daft.functions.arcsinh`](https://docs.daft.ai/en/stable/api/functions/arcsinh/)
    """
    from daft.functions import arcsinh

    return arcsinh(self)

arctan #

arctan() -> Expression

The elementwise arc tangent of a numeric expression.

See Also

daft.functions.arctan

Source code in daft/expressions/expressions.py
780
781
782
783
784
785
786
787
788
def arctan(self) -> Expression:
    """The elementwise arc tangent of a numeric expression.

    Tip: See Also
        [`daft.functions.arctan`](https://docs.daft.ai/en/stable/api/functions/arctan/)
    """
    from daft.functions import arctan

    return arctan(self)

arctan2 #

arctan2(other: Expression) -> Expression

Calculates the four quadrant arctangent of coordinates (y, x), in radians.

See Also

daft.functions.arctan2

Source code in daft/expressions/expressions.py
790
791
792
793
794
795
796
797
798
def arctan2(self, other: Expression) -> Expression:
    """Calculates the four quadrant arctangent of coordinates (y, x), in radians.

    Tip: See Also
        [`daft.functions.arctan2`](https://docs.daft.ai/en/stable/api/functions/arctan2/)
    """
    from daft.functions import arctan2

    return arctan2(self, other)

arctanh #

arctanh() -> Expression

The elementwise inverse hyperbolic tangent of a numeric expression.

See Also

daft.functions.arctanh

Source code in daft/expressions/expressions.py
800
801
802
803
804
805
806
807
808
def arctanh(self) -> Expression:
    """The elementwise inverse hyperbolic tangent of a numeric expression.

    Tip: See Also
        [`daft.functions.arctanh`](https://docs.daft.ai/en/stable/api/functions/arctanh/)
    """
    from daft.functions import arctanh

    return arctanh(self)

as_binary #

as_binary() -> Expression
Source code in daft/expressions/expressions.py
539
def as_binary(self) -> Expression: ...

as_bool #

as_bool() -> Expression
Source code in daft/expressions/expressions.py
537
def as_bool(self) -> Expression: ...

as_date #

as_date() -> Expression
Source code in daft/expressions/expressions.py
547
def as_date(self) -> Expression: ...

as_decimal128 #

as_decimal128(precision: int, scale: int) -> Expression
Source code in daft/expressions/expressions.py
545
def as_decimal128(self, precision: int, scale: int) -> Expression: ...

as_duration #

as_duration(timeunit: TimeUnit | str) -> Expression
Source code in daft/expressions/expressions.py
553
def as_duration(self, timeunit: TimeUnit | str) -> Expression: ...

as_embedding #

as_embedding(dtype: DataType, size: int) -> Expression
Source code in daft/expressions/expressions.py
567
def as_embedding(self, dtype: DataType, size: int) -> Expression: ...

as_extension #

as_extension(name: str, storage_dtype: DataType, metadata: str | None = ...) -> Expression
Source code in daft/expressions/expressions.py
565
def as_extension(self, name: str, storage_dtype: DataType, metadata: str | None = ...) -> Expression: ...

as_file #

as_file(media_type: MediaType = ...) -> Expression
Source code in daft/expressions/expressions.py
584
def as_file(self, media_type: MediaType = ...) -> Expression: ...

as_fixed_size_binary #

as_fixed_size_binary(size: int) -> Expression
Source code in daft/expressions/expressions.py
541
def as_fixed_size_binary(self, size: int) -> Expression: ...

as_fixed_size_list #

as_fixed_size_list(dtype: DataType, size: int) -> Expression
Source code in daft/expressions/expressions.py
559
def as_fixed_size_list(self, dtype: DataType, size: int) -> Expression: ...

as_float32 #

as_float32() -> Expression
Source code in daft/expressions/expressions.py
531
def as_float32(self) -> Expression: ...

as_float64 #

as_float64() -> Expression
Source code in daft/expressions/expressions.py
533
def as_float64(self) -> Expression: ...

as_image #

as_image(mode: str | ImageMode | None = ..., height: int | None = ..., width: int | None = ...) -> Expression
Source code in daft/expressions/expressions.py
569
570
571
def as_image(
    self, mode: str | ImageMode | None = ..., height: int | None = ..., width: int | None = ...
) -> Expression: ...

as_int16 #

as_int16() -> Expression
Source code in daft/expressions/expressions.py
517
def as_int16(self) -> Expression: ...

as_int32 #

as_int32() -> Expression
Source code in daft/expressions/expressions.py
519
def as_int32(self) -> Expression: ...

as_int64 #

as_int64() -> Expression
Source code in daft/expressions/expressions.py
521
def as_int64(self) -> Expression: ...

as_int8 #

as_int8() -> Expression
Source code in daft/expressions/expressions.py
515
def as_int8(self) -> Expression: ...

as_interval #

as_interval() -> Expression
Source code in daft/expressions/expressions.py
555
def as_interval(self) -> Expression: ...

as_list #

as_list(dtype: DataType) -> Expression
Source code in daft/expressions/expressions.py
557
def as_list(self, dtype: DataType) -> Expression: ...

as_map #

as_map(key_type: DataType, value_type: DataType) -> Expression
Source code in daft/expressions/expressions.py
561
def as_map(self, key_type: DataType, value_type: DataType) -> Expression: ...

as_null #

as_null() -> Expression
Source code in daft/expressions/expressions.py
543
def as_null(self) -> Expression: ...

as_py #

as_py() -> Any

Returns this literal expression as a python value, raises a ValueError if this is not a literal expression.

Source code in daft/expressions/expressions.py
172
173
174
def as_py(self) -> Any:
    """Returns this literal expression as a python value, raises a ValueError if this is not a literal expression."""
    return self._expr.as_py()

as_python #

as_python() -> Expression
Source code in daft/expressions/expressions.py
582
def as_python(self) -> Expression: ...

as_sparse_tensor #

as_sparse_tensor(dtype: DataType, shape: tuple[int, ...] | None = ..., use_offset_indices: bool = ...) -> Expression
Source code in daft/expressions/expressions.py
575
576
577
578
579
580
def as_sparse_tensor(
    self,
    dtype: DataType,
    shape: tuple[int, ...] | None = ...,
    use_offset_indices: bool = ...,
) -> Expression: ...

as_string #

as_string() -> Expression
Source code in daft/expressions/expressions.py
535
def as_string(self) -> Expression: ...

as_struct #

as_struct(fields: dict[str, DataType]) -> Expression
Source code in daft/expressions/expressions.py
563
def as_struct(self, fields: dict[str, DataType]) -> Expression: ...

as_tensor #

as_tensor(dtype: DataType, shape: tuple[int, ...] | None = ...) -> Expression
Source code in daft/expressions/expressions.py
573
def as_tensor(self, dtype: DataType, shape: tuple[int, ...] | None = ...) -> Expression: ...

as_time #

as_time(timeunit: TimeUnit | str) -> Expression
Source code in daft/expressions/expressions.py
549
def as_time(self, timeunit: TimeUnit | str) -> Expression: ...

as_timestamp #

as_timestamp(timeunit: TimeUnit | str, timezone: str | None = ...) -> Expression
Source code in daft/expressions/expressions.py
551
def as_timestamp(self, timeunit: TimeUnit | str, timezone: str | None = ...) -> Expression: ...

as_uint16 #

as_uint16() -> Expression
Source code in daft/expressions/expressions.py
525
def as_uint16(self) -> Expression: ...

as_uint32 #

as_uint32() -> Expression
Source code in daft/expressions/expressions.py
527
def as_uint32(self) -> Expression: ...

as_uint64 #

as_uint64() -> Expression
Source code in daft/expressions/expressions.py
529
def as_uint64(self) -> Expression: ...

as_uint8 #

as_uint8() -> Expression
Source code in daft/expressions/expressions.py
523
def as_uint8(self) -> Expression: ...

avg #

avg() -> Expression

Alias for Expression.mean(). Check Expression.mean for more details.

Source code in daft/expressions/expressions.py
1060
1061
1062
1063
1064
def avg(self) -> Expression:
    """Alias for `Expression.mean()`. Check [`Expression.mean`](https://docs.daft.ai/en/stable/api/expressions/#daft.expressions.Expression.mean) for more details."""
    from daft.functions import mean

    return mean(self)

between #

between(lower: int | float, upper: int | float) -> Expression

Checks if values in the Expression are between lower and upper, inclusive.

See Also

daft.functions.between

Source code in daft/expressions/expressions.py
1314
1315
1316
1317
1318
1319
1320
1321
1322
def between(self, lower: int | builtins.float, upper: int | builtins.float) -> Expression:
    """Checks if values in the Expression are between lower and upper, inclusive.

    Tip: See Also
        [`daft.functions.between`](https://docs.daft.ai/en/stable/api/functions/between/)
    """
    from daft.functions import between

    return between(self, lower, upper)

bitwise_and #

bitwise_and(other: Expression) -> Expression

Bitwise AND of two integer expressions.

See Also

daft.functions.bitwise_and

Source code in daft/expressions/expressions.py
940
941
942
943
944
945
946
947
948
def bitwise_and(self, other: Expression) -> Expression:
    """Bitwise AND of two integer expressions.

    Tip: See Also
        [`daft.functions.bitwise_and`](https://docs.daft.ai/en/stable/api/functions/bitwise_and/)
    """
    from daft.functions import bitwise_and

    return bitwise_and(self, other)

bitwise_or #

bitwise_or(other: Expression) -> Expression

Bitwise OR of two integer expressions.

See Also

daft.functions.bitwise_or

Source code in daft/expressions/expressions.py
950
951
952
953
954
955
956
957
958
def bitwise_or(self, other: Expression) -> Expression:
    """Bitwise OR of two integer expressions.

    Tip: See Also
        [`daft.functions.bitwise_or`](https://docs.daft.ai/en/stable/api/functions/bitwise_or/)
    """
    from daft.functions import bitwise_or

    return bitwise_or(self, other)

bitwise_xor #

bitwise_xor(other: Expression) -> Expression

Bitwise XOR of two integer expressions.

See Also

daft.functions.bitwise_xor

Source code in daft/expressions/expressions.py
960
961
962
963
964
965
966
967
968
def bitwise_xor(self, other: Expression) -> Expression:
    """Bitwise XOR of two integer expressions.

    Tip: See Also
        [`daft.functions.bitwise_xor`](https://docs.daft.ai/en/stable/api/functions/bitwise_xor/)
    """
    from daft.functions import bitwise_xor

    return bitwise_xor(self, other)

bool_and #

bool_and() -> Expression

Calculates the boolean AND of all values in a list.

See Also

daft.functions.bool_and

Source code in daft/expressions/expressions.py
1136
1137
1138
1139
1140
1141
1142
1143
1144
def bool_and(self) -> Expression:
    """Calculates the boolean AND of all values in a list.

    Tip: See Also
        [`daft.functions.bool_and`](https://docs.daft.ai/en/stable/api/functions/bool_and/)
    """
    from daft.functions import bool_and

    return bool_and(self)

bool_or #

bool_or() -> Expression

Calculates the boolean OR of all values in a list.

See Also

daft.functions.bool_or

Source code in daft/expressions/expressions.py
1146
1147
1148
1149
1150
1151
1152
1153
1154
def bool_or(self) -> Expression:
    """Calculates the boolean OR of all values in a list.

    Tip: See Also
        [`daft.functions.bool_or`](https://docs.daft.ai/en/stable/api/functions/bool_or/)
    """
    from daft.functions import bool_or

    return bool_or(self)

capitalize #

capitalize() -> Expression

Capitalize a UTF-8 string.

See Also

daft.functions.capitalize

Source code in daft/expressions/expressions.py
2081
2082
2083
2084
2085
2086
2087
2088
2089
def capitalize(self) -> Expression:
    """Capitalize a UTF-8 string.

    Tip: See Also
        [`daft.functions.capitalize`](https://docs.daft.ai/en/stable/api/functions/capitalize/)
    """
    from daft.functions import capitalize

    return capitalize(self)

cast #

cast(dtype: DataTypeLike) -> Expression

Casts an expression to the given datatype if possible.

See Also

daft.functions.cast

Source code in daft/expressions/expressions.py
490
491
492
493
494
495
496
497
498
def cast(self, dtype: DataTypeLike) -> Expression:
    """Casts an expression to the given datatype if possible.

    Tip: See Also
        [`daft.functions.cast`](https://docs.daft.ai/en/stable/api/functions/cast/)
    """
    from daft.functions import cast

    return cast(self, dtype)

cbrt #

cbrt() -> Expression

The cube root of a numeric expression.

See Also

daft.functions.cbrt

Source code in daft/expressions/expressions.py
660
661
662
663
664
665
666
667
668
def cbrt(self) -> Expression:
    """The cube root of a numeric expression.

    Tip: See Also
        [`daft.functions.cbrt`](https://docs.daft.ai/en/stable/api/functions/cbrt/)
    """
    from daft.functions import cbrt

    return cbrt(self)

ceil #

ceil() -> Expression

The ceiling of a numeric expression.

See Also

daft.functions.ceil

Source code in daft/expressions/expressions.py
586
587
588
589
590
591
592
593
594
def ceil(self) -> Expression:
    """The ceiling of a numeric expression.

    Tip: See Also
        [`daft.functions.ceil`](https://docs.daft.ai/en/stable/api/functions/ceil/)
    """
    from daft.functions import ceil

    return ceil(self)

chunk #

chunk(size: int) -> Expression

Splits each list into chunks of the given size.

See Also

daft.functions.chunk

Source code in daft/expressions/expressions.py
2387
2388
2389
2390
2391
2392
2393
2394
2395
def chunk(self, size: int) -> Expression:
    """Splits each list into chunks of the given size.

    Tip: See Also
        [`daft.functions.chunk`](https://docs.daft.ai/en/stable/api/functions/chunk/)
    """
    from daft.functions import chunk

    return chunk(self, size)

clip #

clip(min: Expression | None = None, max: Expression | None = None) -> Expression

Clips an expression to the given minimum and maximum values.

See Also

daft.functions.clip

Source code in daft/expressions/expressions.py
606
607
608
609
610
611
612
613
614
615
616
617
618
def clip(
    self,
    min: Expression | None = None,
    max: Expression | None = None,
) -> Expression:
    """Clips an expression to the given minimum and maximum values.

    Tip: See Also
        [`daft.functions.clip`](https://docs.daft.ai/en/stable/api/functions/clip/)
    """
    from daft.functions import clip

    return clip(self, min, max)

coalesce #

coalesce(*others: Expression) -> Expression

Returns the first non-null value among this expression and the provided expressions.

See Also

daft.functions.coalesce

Source code in daft/expressions/expressions.py
2586
2587
2588
2589
2590
2591
2592
2593
2594
def coalesce(self, *others: Expression) -> Expression:
    """Returns the first non-null value among this expression and the provided expressions.

    Tip: See Also
        [`daft.functions.coalesce`](https://docs.daft.ai/en/stable/api/functions/coalesce/)
    """
    from daft.functions import coalesce

    return coalesce(self, *others)

column_name #

column_name() -> str | None
Source code in daft/expressions/expressions.py
156
157
def column_name(self) -> builtins.str | None:
    return self._expr.column_name()

compress #

compress(codec: COMPRESSION_CODEC) -> Expression

Compress binary or string values using the specified codec.

See Also

daft.functions.compress

Source code in daft/expressions/expressions.py
1420
1421
1422
1423
1424
1425
1426
1427
1428
def compress(self, codec: COMPRESSION_CODEC) -> Expression:
    """Compress binary or string values using the specified codec.

    Tip: See Also
        [`daft.functions.compress`](https://docs.daft.ai/en/stable/api/functions/compress/)
    """
    from daft.functions import compress

    return compress(self, codec=codec)

concat #

concat(other: Expression | str | bytes) -> Expression

Concatenate two string expressions.

See Also

daft.functions.concat

Source code in daft/expressions/expressions.py
1668
1669
1670
1671
1672
1673
1674
1675
1676
def concat(self, other: Expression | builtins.str | bytes) -> Expression:
    """Concatenate two string expressions.

    Tip: See Also
        [`daft.functions.concat`](https://docs.daft.ai/en/stable/api/functions/concat/)
    """
    from daft.functions import concat

    return concat(self, other)

contains #

contains(substr: str | Expression) -> Expression

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

See Also

daft.functions.contains

Source code in daft/expressions/expressions.py
1991
1992
1993
1994
1995
1996
1997
1998
1999
def contains(self, substr: builtins.str | Expression) -> Expression:
    """Checks whether each string contains the given pattern in a string column.

    Tip: See Also
        [`daft.functions.contains`](https://docs.daft.ai/en/stable/api/functions/contains/)
    """
    from daft.functions import contains

    return contains(self, substr)

convert_image #

convert_image(mode: str | ImageMode) -> Expression

Convert an image expression to the specified mode.

See Also

daft.functions.convert_image

Source code in daft/expressions/expressions.py
2674
2675
2676
2677
2678
2679
2680
2681
2682
def convert_image(self, mode: builtins.str | ImageMode) -> Expression:
    """Convert an image expression to the specified mode.

    Tip: See Also
        [`daft.functions.convert_image`](https://docs.daft.ai/en/stable/api/functions/convert_image/)
    """
    from daft.functions import convert_image

    return convert_image(self, mode)

convert_time_zone #

convert_time_zone(to_timezone: str, from_timezone: str | None = None) -> Expression

Converts a timestamp to another timezone while preserving the instant in time.

See Also

daft.functions.convert_time_zone

Source code in daft/expressions/expressions.py
1971
1972
1973
1974
1975
1976
1977
1978
1979
def convert_time_zone(self, to_timezone: builtins.str, from_timezone: builtins.str | None = None) -> Expression:
    """Converts a timestamp to another timezone while preserving the instant in time.

    Tip: See Also
        [`daft.functions.convert_time_zone`](https://docs.daft.ai/en/stable/api/functions/convert_time_zone/)
    """
    from daft.functions import convert_time_zone

    return convert_time_zone(self, to_timezone, from_timezone)

cos #

cos() -> Expression

The elementwise cosine of a numeric expression.

See Also

daft.functions.cos

Source code in daft/expressions/expressions.py
680
681
682
683
684
685
686
687
688
def cos(self) -> Expression:
    """The elementwise cosine of a numeric expression.

    Tip: See Also
        [`daft.functions.cos`](https://docs.daft.ai/en/stable/api/functions/cos/)
    """
    from daft.functions import cos

    return cos(self)

cosh #

cosh() -> Expression

The elementwise hyperbolic cosine of a numeric expression.

See Also

daft.functions.cosh

Source code in daft/expressions/expressions.py
740
741
742
743
744
745
746
747
748
def cosh(self) -> Expression:
    """The elementwise hyperbolic cosine of a numeric expression.

    Tip: See Also
        [`daft.functions.cosh`](https://docs.daft.ai/en/stable/api/functions/cosh/)
    """
    from daft.functions import cosh

    return cosh(self)

cosine_distance #

cosine_distance(other: Expression) -> Expression

Compute the cosine distance between two embeddings.

See Also

daft.functions.cosine_distance

Source code in daft/expressions/expressions.py
1598
1599
1600
1601
1602
1603
1604
1605
1606
def cosine_distance(self, other: Expression) -> Expression:
    """Compute the cosine distance between two embeddings.

    Tip: See Also
        [`daft.functions.cosine_distance`](https://docs.daft.ai/en/stable/api/functions/cosine_distance/)
    """
    from daft.functions import cosine_distance

    return cosine_distance(self, other)

cosine_similarity #

cosine_similarity(other: Expression) -> Expression

Compute the cosine similarity between two embeddings.

See Also

daft.functions.cosine_similarity

Source code in daft/expressions/expressions.py
1628
1629
1630
1631
1632
1633
1634
1635
1636
def cosine_similarity(self, other: Expression) -> Expression:
    """Compute the cosine similarity between two embeddings.

    Tip: See Also
        [`daft.functions.cosine_similarity`](https://docs.daft.ai/en/stable/api/functions/cosine_similarity/)
    """
    from daft.functions import cosine_similarity

    return cosine_similarity(self, other)

cot #

cot() -> Expression

The elementwise cotangent of a numeric expression.

See Also

daft.functions.cot

Source code in daft/expressions/expressions.py
720
721
722
723
724
725
726
727
728
def cot(self) -> Expression:
    """The elementwise cotangent of a numeric expression.

    Tip: See Also
        [`daft.functions.cot`](https://docs.daft.ai/en/stable/api/functions/cot/)
    """
    from daft.functions import cot

    return cot(self)

count #

count(mode: Literal['all', 'valid', 'null'] | CountMode = Valid) -> Expression

Counts the number of values in the expression.

See Also

daft.functions.count

Source code in daft/expressions/expressions.py
990
991
992
993
994
995
996
997
998
def count(self, mode: Literal["all", "valid", "null"] | CountMode = CountMode.Valid) -> Expression:
    """Counts the number of values in the expression.

    Tip: See Also
        [`daft.functions.count`](https://docs.daft.ai/en/stable/api/functions/count)
    """
    from daft.functions import count

    return count(self, mode=mode)

count_distinct #

count_distinct() -> Expression

Counts the number of distinct values in the expression.

See Also

daft.functions.count_distinct

Source code in daft/expressions/expressions.py
1000
1001
1002
1003
1004
1005
1006
1007
1008
def count_distinct(self) -> Expression:
    """Counts the number of distinct values in the expression.

    Tip: See Also
        [`daft.functions.count_distinct`](https://docs.daft.ai/en/stable/api/functions/count_distinct)
    """
    from daft.functions import count_distinct

    return count_distinct(self)

count_matches #

count_matches(patterns: Any, *, whole_words: bool = False, case_sensitive: bool = True) -> Expression

Counts the number of times a pattern, or multiple patterns, appear in a string.

See Also

daft.functions.count_matches

Source code in daft/expressions/expressions.py
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
def count_matches(
    self,
    patterns: Any,
    *,
    whole_words: bool = False,
    case_sensitive: bool = True,
) -> Expression:
    """Counts the number of times a pattern, or multiple patterns, appear in a string.

    Tip: See Also
        [`daft.functions.count_matches`](https://docs.daft.ai/en/stable/api/functions/count_matches/)
    """
    from daft.functions import count_matches

    return count_matches(self, patterns, whole_words=whole_words, case_sensitive=case_sensitive)

crop #

crop(bbox: tuple[int, int, int, int] | Expression) -> Expression

Crops images with the provided bounding box.

See Also

daft.functions.crop

Source code in daft/expressions/expressions.py
2407
2408
2409
2410
2411
2412
2413
2414
2415
def crop(self, bbox: tuple[int, int, int, int] | Expression) -> Expression:
    """Crops images with the provided bounding box.

    Tip: See Also
        [`daft.functions.crop`](https://docs.daft.ai/en/stable/api/functions/crop/)
    """
    from daft.functions import crop

    return crop(self, bbox)

csc #

csc() -> Expression

The elementwise cosecant of a numeric expression.

See Also

daft.functions.csc

Source code in daft/expressions/expressions.py
700
701
702
703
704
705
706
707
708
def csc(self) -> Expression:
    """The elementwise cosecant of a numeric expression.

    Tip: See Also
        [`daft.functions.csc`](https://docs.daft.ai/en/stable/api/functions/csc/)
    """
    from daft.functions import csc

    return csc(self)

date #

date() -> Expression

Retrieves the date for a datetime column.

Source code in daft/expressions/expressions.py
1709
1710
1711
1712
1713
def date(self) -> Expression:
    """Retrieves the date for a datetime column."""
    from daft.functions import date

    return date(self)

date_trunc #

date_trunc(interval: str, relative_to: Expression | None = None) -> Expression

Truncates the datetime column to the specified interval.

See Also

daft.functions.date_trunc

Source code in daft/expressions/expressions.py
2596
2597
2598
2599
2600
2601
2602
2603
2604
def date_trunc(self, interval: builtins.str, relative_to: Expression | None = None) -> Expression:
    """Truncates the datetime column to the specified interval.

    Tip: See Also
        [`daft.functions.date_trunc`](https://docs.daft.ai/en/stable/api/functions/date_trunc/)
    """
    from daft.functions import date_trunc

    return date_trunc(interval, self, relative_to=relative_to)

day #

day() -> Expression

Retrieves the day for a datetime column.

See Also

daft.functions.day

Source code in daft/expressions/expressions.py
1715
1716
1717
1718
1719
1720
1721
1722
1723
def day(self) -> Expression:
    """Retrieves the day for a datetime column.

    Tip: See Also
        [`daft.functions.day`](https://docs.daft.ai/en/stable/api/functions/day/)
    """
    from daft.functions import day

    return day(self)

day_of_month #

day_of_month() -> Expression

Retrieves the day of the month for a datetime column.

See Also

daft.functions.day_of_month

Source code in daft/expressions/expressions.py
1841
1842
1843
1844
1845
1846
1847
1848
1849
def day_of_month(self) -> Expression:
    """Retrieves the day of the month for a datetime column.

    Tip: See Also
        [`daft.functions.day_of_month`](https://docs.daft.ai/en/stable/api/functions/day_of_month/)
    """
    from daft.functions import day_of_month

    return day_of_month(self)

day_of_week #

day_of_week() -> Expression

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

See Also

daft.functions.day_of_week

Source code in daft/expressions/expressions.py
1831
1832
1833
1834
1835
1836
1837
1838
1839
def day_of_week(self) -> Expression:
    """Retrieves the day of the week for a datetime column, starting at 0 for Monday and ending at 6 for Sunday.

    Tip: See Also
        [`daft.functions.day_of_week`](https://docs.daft.ai/en/stable/api/functions/day_of_week/)
    """
    from daft.functions import day_of_week

    return day_of_week(self)

day_of_year #

day_of_year() -> Expression

Retrieves the ordinal day for a datetime column. Starting at 1 for January 1st and ending at 365 or 366 for December 31st.

See Also

daft.functions.day_of_year

Source code in daft/expressions/expressions.py
1851
1852
1853
1854
1855
1856
1857
1858
1859
def day_of_year(self) -> Expression:
    """Retrieves the ordinal day for a datetime column. Starting at 1 for January 1st and ending at 365 or 366 for December 31st.

    Tip: See Also
        [`daft.functions.day_of_year`](https://docs.daft.ai/en/stable/api/functions/day_of_year/)
    """
    from daft.functions import day_of_year

    return day_of_year(self)

decode #

decode(charset: ENCODING_CHARSET) -> Expression

Decodes binary values using the specified character set.

See Also

daft.functions.decode

Source code in daft/expressions/expressions.py
1390
1391
1392
1393
1394
1395
1396
1397
1398
def decode(self, charset: ENCODING_CHARSET) -> Expression:
    """Decodes binary values using the specified character set.

    Tip: See Also
        [`daft.functions.decode`](https://docs.daft.ai/en/stable/api/functions/decode/)
    """
    from daft.functions import decode

    return decode(self, charset=charset)

decode_image #

decode_image(on_error: Literal['raise', 'null'] = 'raise', mode: str | ImageMode | None = RGB) -> Expression

Decodes the binary data in this column into images.

See Also

daft.functions.decode_image

Source code in daft/expressions/expressions.py
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
def decode_image(
    self,
    on_error: Literal["raise", "null"] = "raise",
    mode: builtins.str | ImageMode | None = ImageMode.RGB,
) -> Expression:
    """Decodes the binary data in this column into images.

    Tip: See Also
        [`daft.functions.decode_image`](https://docs.daft.ai/en/stable/api/functions/decode_image/)
    """
    from daft.functions import decode_image

    return decode_image(self, on_error=on_error, mode=mode)

decode_image_file #

decode_image_file() -> Expression

Decodes an image file into an Image column.

Source code in daft/expressions/expressions.py
3003
3004
3005
3006
3007
def decode_image_file(self) -> Expression:
    """Decodes an image file into an Image column."""
    from daft.functions import decode_image_file

    return decode_image_file(self)

decompress #

decompress(codec: COMPRESSION_CODEC) -> Expression

Decompress binary values using the specified codec.

See Also

daft.functions.decompress

Source code in daft/expressions/expressions.py
1430
1431
1432
1433
1434
1435
1436
1437
1438
def decompress(self, codec: COMPRESSION_CODEC) -> Expression:
    """Decompress binary values using the specified codec.

    Tip: See Also
        [`daft.functions.decompress`](https://docs.daft.ai/en/stable/api/functions/decompress/)
    """
    from daft.functions import decompress

    return decompress(self, codec=codec)

degrees #

degrees() -> Expression

The elementwise degrees of a numeric expression.

See Also

daft.functions.degrees

Source code in daft/expressions/expressions.py
840
841
842
843
844
845
846
847
848
def degrees(self) -> Expression:
    """The elementwise degrees of a numeric expression.

    Tip: See Also
        [`daft.functions.degrees`](https://docs.daft.ai/en/stable/api/functions/degrees/)
    """
    from daft.functions import degrees

    return degrees(self)

deserialize #

deserialize(format: Literal['json'], dtype: DataTypeLike) -> Expression

Deserializes the expression (string) using the specified format and data type.

See Also

daft.functions.deserialize

Source code in daft/expressions/expressions.py
1460
1461
1462
1463
1464
1465
1466
1467
1468
def deserialize(self, format: Literal["json"], dtype: DataTypeLike) -> Expression:
    """Deserializes the expression (string) using the specified format and data type.

    Tip: See Also
        [`daft.functions.deserialize`](https://docs.daft.ai/en/stable/api/functions/deserialize/)
    """
    from daft.functions import deserialize

    return deserialize(self, format=format, dtype=dtype)

dot_product #

dot_product(other: Expression) -> Expression

Compute the dot product between two embeddings.

See Also

daft.functions.dot_product

Source code in daft/expressions/expressions.py
1618
1619
1620
1621
1622
1623
1624
1625
1626
def dot_product(self, other: Expression) -> Expression:
    """Compute the dot product between two embeddings.

    Tip: See Also
        [`daft.functions.dot_product`](https://docs.daft.ai/en/stable/api/functions/dot_product/)
    """
    from daft.functions import dot_product

    return dot_product(self, other)

download #

download(max_connections: int = 32, on_error: Literal['raise', 'null'] = 'raise', io_config: IOConfig | None = None) -> Expression

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

See Also

daft.functions.download

Source code in daft/expressions/expressions.py
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
def download(
    self,
    max_connections: int = 32,
    on_error: Literal["raise", "null"] = "raise",
    io_config: IOConfig | None = None,
) -> Expression:
    """Treats each string as a URL, and downloads the bytes contents as a bytes column.

    Tip: See Also
        [`daft.functions.download`](https://docs.daft.ai/en/stable/api/functions/download/)
    """
    from daft.functions import download

    return download(self, max_connections, on_error, io_config)

encode #

encode(charset: ENCODING_CHARSET) -> Expression

Encode binary or string values using the specified character set.

See Also

daft.functions.encode

Source code in daft/expressions/expressions.py
1380
1381
1382
1383
1384
1385
1386
1387
1388
def encode(self, charset: ENCODING_CHARSET) -> Expression:
    """Encode binary or string values using the specified character set.

    Tip: See Also
        [`daft.functions.encode`](https://docs.daft.ai/en/stable/api/functions/encode/)
    """
    from daft.functions import encode

    return encode(self, charset=charset)

encode_image #

encode_image(image_format: str | ImageFormat) -> Expression

Encode an image column as the provided image file format, returning a binary column of encoded bytes.

See Also

daft.functions.encode_image

Source code in daft/expressions/expressions.py
2562
2563
2564
2565
2566
2567
2568
2569
2570
def encode_image(self, image_format: builtins.str | ImageFormat) -> Expression:
    """Encode an image column as the provided image file format, returning a binary column of encoded bytes.

    Tip: See Also
        [`daft.functions.encode_image`](https://docs.daft.ai/en/stable/api/functions/encode_image/)
    """
    from daft.functions import encode_image

    return encode_image(self, image_format)

endswith #

endswith(suffix: str | Expression) -> Expression

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

See Also

daft.functions.endswith

Source code in daft/expressions/expressions.py
2241
2242
2243
2244
2245
2246
2247
2248
2249
def endswith(self, suffix: builtins.str | Expression) -> Expression:
    """Checks whether each string ends with the given pattern in a string column.

    Tip: See Also
        [`daft.functions.endswith`](https://docs.daft.ai/en/stable/api/functions/endswith/)
    """
    from daft.functions import endswith

    return endswith(self, suffix)

eq_null_safe #

eq_null_safe(other: Expression | Any) -> Expression

Performs a null-safe equality comparison between two expressions.

See Also

daft.functions.eq_null_safe

Source code in daft/expressions/expressions.py
322
323
324
325
326
327
328
329
330
def eq_null_safe(self, other: Expression | Any) -> Expression:
    """Performs a null-safe equality comparison between two expressions.

    Tip: See Also
        [`daft.functions.eq_null_safe`](https://docs.daft.ai/en/stable/api/functions/eq_null_safe/)
    """
    from daft.functions import eq_null_safe

    return eq_null_safe(self, other)

euclidean_distance #

euclidean_distance(other: Expression) -> Expression

Compute the Euclidean distance between two embeddings.

See Also

daft.functions.euclidean_distance

Source code in daft/expressions/expressions.py
1608
1609
1610
1611
1612
1613
1614
1615
1616
def euclidean_distance(self, other: Expression) -> Expression:
    """Compute the Euclidean distance between two embeddings.

    Tip: See Also
        [`daft.functions.euclidean_distance`](https://docs.daft.ai/en/stable/api/functions/euclidean_distance/)
    """
    from daft.functions import euclidean_distance

    return euclidean_distance(self, other)

exp #

exp() -> Expression

The e^self of a numeric expression.

See Also

daft.functions.exp

Source code in daft/expressions/expressions.py
920
921
922
923
924
925
926
927
928
def exp(self) -> Expression:
    """The e^self of a numeric expression.

    Tip: See Also
        [`daft.functions.exp`](https://docs.daft.ai/en/stable/api/functions/exp/)
    """
    from daft.functions import exp

    return exp(self)

explode #

explode(ignore_empty_and_null: bool = False) -> Expression

Explode a list expression.

Parameters:

Name Type Description Default
ignore_empty_and_null bool

If True, drops rows where the list is empty or null. If False (default), empty lists and null values each produce a single row with a null value.

False
See Also

daft.functions.explode

Source code in daft/expressions/expressions.py
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
def explode(self, ignore_empty_and_null: bool = False) -> Expression:
    """Explode a list expression.

    Args:
       ignore_empty_and_null: If True, drops rows where the list is empty or null.
           If False (default), empty lists and null values each produce a single row with a null value.

    Tip: See Also
        [`daft.functions.explode`](https://docs.daft.ai/en/stable/api/functions/explode/)
    """
    from daft.functions import explode

    return explode(self, ignore_empty_and_null=ignore_empty_and_null)

expm1 #

expm1() -> Expression

The e^self - 1 of a numeric expression.

See Also

daft.functions.expm1

Source code in daft/expressions/expressions.py
930
931
932
933
934
935
936
937
938
def expm1(self) -> Expression:
    """The e^self - 1 of a numeric expression.

    Tip: See Also
        [`daft.functions.expm1`](https://docs.daft.ai/en/stable/api/functions/expm1/)
    """
    from daft.functions import expm1

    return expm1(self)

file_path #

file_path() -> Expression

Gets the path (URL) of a file as a string.

See Also

daft.functions.file_path

Source code in daft/expressions/expressions.py
2929
2930
2931
2932
2933
2934
2935
2936
2937
def file_path(self) -> Expression:
    """Gets the path (URL) of a file as a string.

    Tip: See Also
        [`daft.functions.file_path`](https://docs.daft.ai/en/stable/api/functions/file_path/)
    """
    from daft.functions import file_path

    return file_path(self)

file_size #

file_size() -> Expression

Gets the size of a file in bytes.

See Also

daft.functions.file_size

Source code in daft/expressions/expressions.py
2939
2940
2941
2942
2943
2944
2945
2946
2947
def file_size(self) -> Expression:
    """Gets the size of a file in bytes.

    Tip: See Also
        [`daft.functions.file_size`](https://docs.daft.ai/en/stable/api/functions/file_size/)
    """
    from daft.functions import file_size

    return file_size(self)

fill_nan #

fill_nan(fill_value: Expression) -> Expression

Fills NaN values in the Expression with the provided fill_value.

See Also

daft.functions.fill_nan

Source code in daft/expressions/expressions.py
2844
2845
2846
2847
2848
2849
2850
2851
2852
def fill_nan(self, fill_value: Expression) -> Expression:
    """Fills NaN values in the Expression with the provided fill_value.

    Tip: See Also
        [`daft.functions.fill_nan`](https://docs.daft.ai/en/stable/api/functions/fill_nan/)
    """
    from daft.functions import fill_nan

    return fill_nan(self, fill_value)

fill_null #

fill_null(fill_value: Expression | Any) -> Expression

Fills null values in the Expression with the provided fill_value.

See Also

daft.functions.fill_null

Source code in daft/expressions/expressions.py
1291
1292
1293
1294
1295
1296
1297
1298
1299
def fill_null(self, fill_value: Expression | Any) -> Expression:
    """Fills null values in the Expression with the provided fill_value.

    Tip: See Also
        [`daft.functions.fill_null`](https://docs.daft.ai/en/stable/api/functions/fill_null/)
    """
    from daft.functions import fill_null

    return fill_null(self, fill_value)

find #

find(substr: str | Expression) -> Expression

Returns the index of the first occurrence of the substring in each string.

See Also

daft.functions.find

Source code in daft/expressions/expressions.py
2664
2665
2666
2667
2668
2669
2670
2671
2672
def find(self, substr: builtins.str | Expression) -> Expression:
    """Returns the index of the first occurrence of the substring in each string.

    Tip: See Also
        [`daft.functions.find`](https://docs.daft.ai/en/stable/api/functions/find/)
    """
    from daft.functions import find

    return find(self, substr)

first_value #

first_value(ignore_nulls: bool = False) -> Expression

Returns the first value in the window frame.

When ignore_nulls=True, skips null values and returns the first non-null value. Must be used with over() to specify the window.

Source code in daft/expressions/expressions.py
1513
1514
1515
1516
1517
1518
1519
1520
1521
def first_value(self, ignore_nulls: bool = False) -> Expression:
    """Returns the first value in the window frame.

    When ``ignore_nulls=True``, skips null values and returns the first non-null value.
    Must be used with ``over()`` to specify the window.
    """
    from daft.functions import first_value

    return first_value(self, ignore_nulls=ignore_nulls)

floor #

floor() -> Expression

The floor of a numeric expression.

See Also

daft.functions.floor

Source code in daft/expressions/expressions.py
596
597
598
599
600
601
602
603
604
def floor(self) -> Expression:
    """The floor of a numeric expression.

    Tip: See Also
        [`daft.functions.floor`](https://docs.daft.ai/en/stable/api/functions/floor/)
    """
    from daft.functions import floor

    return floor(self)

get #

get(index: int | str | Expression, default: Any = None) -> Expression

Get an index from a list expression or a field from a struct expression.

See Also

daft.functions.get

Source code in daft/expressions/expressions.py
2704
2705
2706
2707
2708
2709
2710
2711
2712
def get(self, index: int | builtins.str | Expression, default: Any = None) -> Expression:
    """Get an index from a list expression or a field from a struct expression.

    Tip: See Also
        [`daft.functions.get`](https://docs.daft.ai/en/stable/api/functions/get/)
    """
    from daft.functions import get

    return get(self, index, default)

hamming_distance #

hamming_distance(other: Expression) -> Expression

Compute the bitwise Hamming distance between two hash fingerprints.

See Also

daft.functions.hamming_distance

Source code in daft/expressions/expressions.py
1370
1371
1372
1373
1374
1375
1376
1377
1378
def hamming_distance(self, other: Expression) -> Expression:
    """Compute the bitwise Hamming distance between two hash fingerprints.

    Tip: See Also
        [`daft.functions.hamming_distance`](https://docs.daft.ai/en/stable/api/functions/hamming_distance/)
    """
    from daft.functions import hamming_distance

    return hamming_distance(self, other)

hamming_distance_str #

hamming_distance_str(other: Expression) -> Expression

Compute the character-level Hamming distance between two strings.

See Also

daft.functions.hamming_distance_str

Source code in daft/expressions/expressions.py
2367
2368
2369
2370
2371
2372
2373
2374
2375
def hamming_distance_str(self, other: Expression) -> Expression:
    """Compute the character-level Hamming distance between two strings.

    Tip: See Also
        [`daft.functions.hamming_distance_str`](https://docs.daft.ai/en/stable/api/functions/hamming_distance_str/)
    """
    from daft.functions import hamming_distance_str

    return hamming_distance_str(self, other)

hash #

hash(seed: Any | None = None, hash_function: Literal['xxhash', 'xxhash32', 'xxhash64', 'xxhash3_64', 'murmurhash3', 'sha1'] | None = 'xxhash') -> Expression

Hashes the values in the Expression.

See Also

daft.functions.hash: use the function for hashing multiple columns together.

Source code in daft/expressions/expressions.py
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
def hash(
    self,
    seed: Any | None = None,
    hash_function: Literal["xxhash", "xxhash32", "xxhash64", "xxhash3_64", "murmurhash3", "sha1"] | None = "xxhash",
) -> Expression:
    """Hashes the values in the Expression.

    Tip: See Also
        [`daft.functions.hash`](https://docs.daft.ai/en/stable/api/functions/hash/): use the function for hashing multiple columns together.
    """
    from daft.functions import hash

    return hash(self, seed=seed, hash_function=hash_function)

hour #

hour() -> Expression

Retrieves the hour for a datetime column.

See Also

daft.functions.hour

Source code in daft/expressions/expressions.py
1725
1726
1727
1728
1729
1730
1731
1732
1733
def hour(self) -> Expression:
    """Retrieves the hour for a datetime column.

    Tip: See Also
        [`daft.functions.hour`](https://docs.daft.ai/en/stable/api/functions/hour/)
    """
    from daft.functions import hour

    return hour(self)

ilike #

ilike(pattern: str | Expression) -> Expression

Checks whether each string matches the given SQL ILIKE pattern, case insensitive.

See Also

daft.functions.ilike

Source code in daft/expressions/expressions.py
2221
2222
2223
2224
2225
2226
2227
2228
2229
def ilike(self, pattern: builtins.str | Expression) -> Expression:
    """Checks whether each string matches the given SQL ILIKE pattern, case insensitive.

    Tip: See Also
        [`daft.functions.ilike`](https://docs.daft.ai/en/stable/api/functions/ilike/)
    """
    from daft.functions import ilike

    return ilike(self, pattern)

image_attribute #

image_attribute(name: Literal['width', 'height', 'channel', 'mode'] | ImageProperty) -> Expression

Get a property of the image, such as 'width', 'height', 'channel', or 'mode'.

See Also

daft.functions.image_attribute

Source code in daft/expressions/expressions.py
2854
2855
2856
2857
2858
2859
2860
2861
2862
def image_attribute(self, name: Literal["width", "height", "channel", "mode"] | ImageProperty) -> Expression:
    """Get a property of the image, such as 'width', 'height', 'channel', or 'mode'.

    Tip: See Also
        [`daft.functions.image_attribute`](https://docs.daft.ai/en/stable/api/functions/image_attribute/)
    """
    from daft.functions import image_attribute

    return image_attribute(self, name)

image_channel #

image_channel() -> Expression

Gets the number of channels in an image.

See Also

daft.functions.image_channel

Source code in daft/expressions/expressions.py
2884
2885
2886
2887
2888
2889
2890
2891
2892
def image_channel(self) -> Expression:
    """Gets the number of channels in an image.

    Tip: See Also
        [`daft.functions.image_channel`](https://docs.daft.ai/en/stable/api/functions/image_channel/)
    """
    from daft.functions import image_channel

    return image_channel(self)

image_file_metadata #

image_file_metadata() -> Expression

Gets metadata for an image file (width, height, format, mode).

Reads only the file header without decoding pixel data.

Source code in daft/expressions/expressions.py
2994
2995
2996
2997
2998
2999
3000
3001
def image_file_metadata(self) -> Expression:
    """Gets metadata for an image file (width, height, format, mode).

    Reads only the file header without decoding pixel data.
    """
    from daft.functions import image_file_metadata

    return image_file_metadata(self)

image_hash #

image_hash(*, method: Literal['phash', 'phash_simple', 'dhash', 'dhash_vertical', 'ahash', 'whash', 'crop_resistant', 'colorhash'] = 'phash', hash_size: int = 8, binbits: int = 3) -> Expression

Computes a perceptual hash of an image.

See Also

daft.functions.image_hash

Source code in daft/expressions/expressions.py
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
def image_hash(
    self,
    *,
    method: Literal[
        "phash",
        "phash_simple",
        "dhash",
        "dhash_vertical",
        "ahash",
        "whash",
        "crop_resistant",
        "colorhash",
    ] = "phash",
    hash_size: int = 8,
    binbits: int = 3,
) -> Expression:
    """Computes a perceptual hash of an image.

    Tip: See Also
        [`daft.functions.image_hash`](https://docs.daft.ai/en/stable/api/functions/image_hash/)
    """
    from daft.functions import image_hash

    return image_hash(self, method=method, hash_size=hash_size, binbits=binbits)

image_height #

image_height() -> Expression

Gets the height of an image in pixels.

See Also

daft.functions.image_height

Source code in daft/expressions/expressions.py
2874
2875
2876
2877
2878
2879
2880
2881
2882
def image_height(self) -> Expression:
    """Gets the height of an image in pixels.

    Tip: See Also
        [`daft.functions.image_height`](https://docs.daft.ai/en/stable/api/functions/image_height/)
    """
    from daft.functions import image_height

    return image_height(self)

image_mode #

image_mode() -> Expression

Gets the mode of an image as a string.

See Also

daft.functions.image_mode

Source code in daft/expressions/expressions.py
2894
2895
2896
2897
2898
2899
2900
2901
2902
def image_mode(self) -> Expression:
    """Gets the mode of an image as a string.

    Tip: See Also
        [`daft.functions.image_mode`](https://docs.daft.ai/en/stable/api/functions/image_mode/)
    """
    from daft.functions import image_mode

    return image_mode(self)

image_to_tensor #

image_to_tensor() -> Expression

Convert an image expression to a tensor, inferring dtype and shape.

See Also

daft.functions.image_to_tensor

Source code in daft/expressions/expressions.py
2684
2685
2686
2687
2688
2689
2690
2691
2692
def image_to_tensor(self) -> Expression:
    """Convert an image expression to a tensor, inferring dtype and shape.

    Tip: See Also
        [`daft.functions.image_to_tensor`](https://docs.daft.ai/en/stable/api/functions/image_to_tensor/)
    """
    from daft.functions import image_to_tensor

    return image_to_tensor(self)

image_width #

image_width() -> Expression

Gets the width of an image in pixels.

See Also

daft.functions.image_width

Source code in daft/expressions/expressions.py
2864
2865
2866
2867
2868
2869
2870
2871
2872
def image_width(self) -> Expression:
    """Gets the width of an image in pixels.

    Tip: See Also
        [`daft.functions.image_width`](https://docs.daft.ai/en/stable/api/functions/image_width/)
    """
    from daft.functions import image_width

    return image_width(self)

is_column #

is_column() -> bool
Source code in daft/expressions/expressions.py
150
151
def is_column(self) -> bool:
    return self._expr.is_column()

is_in #

is_in(other: Iterable[Any] | Expression) -> Expression

Checks if values in the Expression are in the provided iterable.

Parameters:

Name Type Description Default
other Iterable[Any] | Expression

An iterable (list, set, tuple, etc.), Expression, or array-like object containing the values to check against

required
See Also

daft.functions.is_in

Source code in daft/expressions/expressions.py
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
def is_in(self, other: Iterable[Any] | Expression) -> Expression:
    """Checks if values in the Expression are in the provided iterable.

    Args:
        other: An iterable (list, set, tuple, etc.), Expression, or array-like object containing the values to check against

    Tip: See Also
        [`daft.functions.is_in`](https://docs.daft.ai/en/stable/api/functions/is_in/)
    """
    from daft.functions import is_in

    return is_in(self, other)

is_inf #

is_inf() -> Expression

Checks if values in the Expression are Infinity.

See Also

daft.functions.is_inf

Source code in daft/expressions/expressions.py
2824
2825
2826
2827
2828
2829
2830
2831
2832
def is_inf(self) -> Expression:
    """Checks if values in the Expression are Infinity.

    Tip: See Also
        [`daft.functions.is_inf`](https://docs.daft.ai/en/stable/api/functions/is_inf/)
    """
    from daft.functions import is_inf

    return is_inf(self)

is_literal #

is_literal() -> bool
Source code in daft/expressions/expressions.py
153
154
def is_literal(self) -> bool:
    return self._expr.is_literal()

is_nan #

is_nan() -> Expression

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

See Also

daft.functions.is_nan

Source code in daft/expressions/expressions.py
2814
2815
2816
2817
2818
2819
2820
2821
2822
def is_nan(self) -> Expression:
    """Checks if values are NaN (a special float value indicating not-a-number).

    Tip: See Also
        [`daft.functions.is_nan`](https://docs.daft.ai/en/stable/api/functions/is_nan/)
    """
    from daft.functions import is_nan

    return is_nan(self)

is_null #

is_null() -> Expression

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

See Also

daft.functions.is_null

Source code in daft/expressions/expressions.py
1271
1272
1273
1274
1275
1276
1277
1278
1279
def is_null(self) -> Expression:
    """Checks if values in the Expression are Null (a special value indicating missing data).

    Tip: See Also
        [`daft.functions.is_null`](https://docs.daft.ai/en/stable/api/functions/is_null/)
    """
    from daft.functions import is_null

    return is_null(self)

jaccard_similarity #

jaccard_similarity(other: Expression) -> Expression

Compute the Jaccard similarity between two embeddings.

See Also

daft.functions.jaccard_similarity

Source code in daft/expressions/expressions.py
1648
1649
1650
1651
1652
1653
1654
1655
1656
def jaccard_similarity(self, other: Expression) -> Expression:
    """Compute the Jaccard similarity between two embeddings.

    Tip: See Also
        [`daft.functions.jaccard_similarity`](https://docs.daft.ai/en/stable/api/functions/jaccard_similarity/)
    """
    from daft.functions import jaccard_similarity

    return jaccard_similarity(self, other)

jq #

jq(filter: str) -> Expression

Applies a jq filter to the expression (string), returning the results as a string.

See Also

daft.functions.jq

Source code in daft/expressions/expressions.py
1490
1491
1492
1493
1494
1495
1496
1497
1498
def jq(self, filter: builtins.str) -> Expression:
    """Applies a [jq](https://jqlang.github.io/jq/manual/) filter to the expression (string), returning the results as a string.

    Tip: See Also
        [`daft.functions.jq`](https://docs.daft.ai/en/stable/api/functions/jq/)
    """
    from daft.functions import jq

    return jq(self, filter)

last_value #

last_value(ignore_nulls: bool = False) -> Expression

Returns the last value in the window frame.

When ignore_nulls=True, skips null values and returns the last non-null value. Must be used with over() to specify the window.

Source code in daft/expressions/expressions.py
1523
1524
1525
1526
1527
1528
1529
1530
1531
def last_value(self, ignore_nulls: bool = False) -> Expression:
    """Returns the last value in the window frame.

    When ``ignore_nulls=True``, skips null values and returns the last non-null value.
    Must be used with ``over()`` to specify the window.
    """
    from daft.functions import last_value

    return last_value(self, ignore_nulls=ignore_nulls)

left #

left(nchars: int | Expression) -> Expression

Gets the n (from nchars) left-most characters of each string.

See Also

daft.functions.left

Source code in daft/expressions/expressions.py
2161
2162
2163
2164
2165
2166
2167
2168
2169
def left(self, nchars: int | Expression) -> Expression:
    """Gets the n (from nchars) left-most characters of each string.

    Tip: See Also
        [`daft.functions.left`](https://docs.daft.ai/en/stable/api/functions/left/)
    """
    from daft.functions import left

    return left(self, nchars)

length #

length() -> Expression

Retrieves the length of the given expression.

See Also

daft.functions.length

Source code in daft/expressions/expressions.py
1658
1659
1660
1661
1662
1663
1664
1665
1666
def length(self) -> Expression:
    """Retrieves the length of the given expression.

    Tip: See Also
        [`daft.functions.length`](https://docs.daft.ai/en/stable/api/functions/length/)
    """
    from daft.functions import length

    return length(self)

length_bytes #

length_bytes() -> Expression

Retrieves the length for a UTF-8 string column in bytes.

See Also

daft.functions.length_bytes

Source code in daft/expressions/expressions.py
2357
2358
2359
2360
2361
2362
2363
2364
2365
def length_bytes(self) -> Expression:
    """Retrieves the length for a UTF-8 string column in bytes.

    Tip: See Also
        [`daft.functions.length_bytes`](https://docs.daft.ai/en/stable/api/functions/length_bytes/)
    """
    from daft.functions import length_bytes

    return length_bytes(self)

like #

like(pattern: str | Expression) -> Expression

Checks whether each string matches the given SQL LIKE pattern, case sensitive.

See Also

daft.functions.like

Source code in daft/expressions/expressions.py
2211
2212
2213
2214
2215
2216
2217
2218
2219
def like(self, pattern: builtins.str | Expression) -> Expression:
    """Checks whether each string matches the given SQL LIKE pattern, case sensitive.

    Tip: See Also
        [`daft.functions.like`](https://docs.daft.ai/en/stable/api/functions/like/)
    """
    from daft.functions import like

    return like(self, pattern)

list_agg #

list_agg() -> Expression

Aggregates the values in the expression into a list.

See Also

daft.functions.list_agg

Source code in daft/expressions/expressions.py
1176
1177
1178
1179
1180
1181
1182
1183
1184
def list_agg(self) -> Expression:
    """Aggregates the values in the expression into a list.

    Tip: See Also
        [`daft.functions.list_agg`](https://docs.daft.ai/en/stable/api/functions/list_agg/)
    """
    from daft.functions import list_agg

    return list_agg(self)

list_agg_distinct #

list_agg_distinct() -> Expression

Aggregates the values in the expression into a list of distinct values (ignoring nulls).

See Also

daft.functions.list_agg_distinct

Source code in daft/expressions/expressions.py
1186
1187
1188
1189
1190
1191
1192
1193
1194
def list_agg_distinct(self) -> Expression:
    """Aggregates the values in the expression into a list of distinct values (ignoring nulls).

    Tip: See Also
        [`daft.functions.list_agg_distinct`](https://docs.daft.ai/en/stable/api/functions/list_agg_distinct/)
    """
    from daft.functions import list_agg_distinct

    return list_agg_distinct(self)

list_append #

list_append(other: Expression) -> Expression

Appends a value to each list in the column.

See Also

daft.functions.list_append

Source code in daft/expressions/expressions.py
2694
2695
2696
2697
2698
2699
2700
2701
2702
def list_append(self, other: Expression) -> Expression:
    """Appends a value to each list in the column.

    Tip: See Also
        [`daft.functions.list_append`](https://docs.daft.ai/en/stable/api/functions/list_append/)
    """
    from daft.functions import list_append

    return list_append(self, other)

list_bool_and #

list_bool_and() -> Expression

Calculates the boolean AND of all values in a list.

See Also

daft.functions.list_bool_and

Source code in daft/expressions/expressions.py
2490
2491
2492
2493
2494
2495
2496
2497
2498
def list_bool_and(self) -> Expression:
    """Calculates the boolean AND of all values in a list.

    Tip: See Also
        [`daft.functions.list_bool_and`](https://docs.daft.ai/en/stable/api/functions/list_bool_and/)
    """
    from daft.functions import list_bool_and

    return list_bool_and(self)

list_bool_or #

list_bool_or() -> Expression

Calculates the boolean OR of all values in a list.

See Also

daft.functions.list_bool_or

Source code in daft/expressions/expressions.py
2500
2501
2502
2503
2504
2505
2506
2507
2508
def list_bool_or(self) -> Expression:
    """Calculates the boolean OR of all values in a list.

    Tip: See Also
        [`daft.functions.list_bool_or`](https://docs.daft.ai/en/stable/api/functions/list_bool_or/)
    """
    from daft.functions import list_bool_or

    return list_bool_or(self)

list_contains #

list_contains(item: Expression) -> Expression

Checks if each list contains the specified item.

See Also

daft.functions.list_contains

Source code in daft/expressions/expressions.py
2532
2533
2534
2535
2536
2537
2538
2539
2540
def list_contains(self, item: Expression) -> Expression:
    """Checks if each list contains the specified item.

    Tip: See Also
        [`daft.functions.list_contains`](https://docs.daft.ai/en/stable/api/functions/list_contains/)
    """
    from daft.functions import list_contains

    return list_contains(self, item)

list_count #

list_count(mode: Literal['all', 'valid', 'null'] | CountMode = Valid) -> Expression

Counts the number of elements in each list.

See Also

daft.functions.list_count

Source code in daft/expressions/expressions.py
2440
2441
2442
2443
2444
2445
2446
2447
2448
def list_count(self, mode: Literal["all", "valid", "null"] | CountMode = CountMode.Valid) -> Expression:
    """Counts the number of elements in each list.

    Tip: See Also
        [`daft.functions.list_count`](https://docs.daft.ai/en/stable/api/functions/list_count/)
    """
    from daft.functions import list_count

    return list_count(self, mode)

list_distinct #

list_distinct() -> Expression

Returns a list of unique elements in each list, preserving order of first occurrence and ignoring nulls.

See Also

daft.functions.list_distinct

Source code in daft/expressions/expressions.py
2522
2523
2524
2525
2526
2527
2528
2529
2530
def list_distinct(self) -> Expression:
    """Returns a list of unique elements in each list, preserving order of first occurrence and ignoring nulls.

    Tip: See Also
        [`daft.functions.list_distinct`](https://docs.daft.ai/en/stable/api/functions/list_distinct/)
    """
    from daft.functions import list_distinct

    return list_distinct(self)

list_filter #

list_filter(predicate: Expression) -> Expression

Filters elements in the list using a boolean predicate over daft.element().

See Also

daft.functions.list_filter

Source code in daft/expressions/expressions.py
2552
2553
2554
2555
2556
2557
2558
2559
2560
def list_filter(self, predicate: Expression) -> Expression:
    """Filters elements in the list using a boolean predicate over `daft.element()`.

    Tip: See Also
        [`daft.functions.list_filter`](https://docs.daft.ai/en/stable/api/functions/list_filter/)
    """
    from daft.functions import list_filter

    return list_filter(self, predicate)

list_flatten #

list_flatten() -> Expression

Flattens one level of nesting in each list.

Outer null rows are preserved as null. Null inner lists are skipped while flattening, and null leaf values are preserved in the output.

See Also

daft.functions.list_flatten

Source code in daft/expressions/expressions.py
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
def list_flatten(self) -> Expression:
    """Flattens one level of nesting in each list.

    Outer null rows are preserved as null. Null inner lists are skipped while flattening,
    and null leaf values are preserved in the output.

    Tip: See Also
        [`daft.functions.list_flatten`](https://docs.daft.ai/en/stable/api/functions/list_flatten/)
    """
    from daft.functions import list_flatten

    return list_flatten(self)

list_join #

list_join(delimiter: str | Expression) -> Expression

Joins every element of a list using the specified string delimiter.

See Also

daft.functions.list_join

Source code in daft/expressions/expressions.py
2417
2418
2419
2420
2421
2422
2423
2424
2425
def list_join(self, delimiter: builtins.str | Expression) -> Expression:
    """Joins every element of a list using the specified string delimiter.

    Tip: See Also
        [`daft.functions.list_join`](https://docs.daft.ai/en/stable/api/functions/list_join/)
    """
    from daft.functions import list_join

    return list_join(self, delimiter)

list_map #

list_map(mapper: Expression) -> Expression

Evaluates an expression on all elements in the list.

See Also

daft.functions.list_map

Source code in daft/expressions/expressions.py
2542
2543
2544
2545
2546
2547
2548
2549
2550
def list_map(self, mapper: Expression) -> Expression:
    """Evaluates an expression on all elements in the list.

    Tip: See Also
        [`daft.functions.list_map`](https://docs.daft.ai/en/stable/api/functions/list_map/)
    """
    from daft.functions import list_map

    return list_map(self, mapper)

list_max #

list_max() -> Expression

Calculates the maximum of each list. If no non-null values in a list, the result is null.

See Also

daft.functions.list_max

Source code in daft/expressions/expressions.py
2480
2481
2482
2483
2484
2485
2486
2487
2488
def list_max(self) -> Expression:
    """Calculates the maximum of each list. If no non-null values in a list, the result is null.

    Tip: See Also
        [`daft.functions.list_max`](https://docs.daft.ai/en/stable/api/functions/list_max/)
    """
    from daft.functions import list_max

    return list_max(self)

list_mean #

list_mean() -> Expression

Calculates the mean of each list. If no non-null values in a list, the result is null.

See Also

daft.functions.list_mean

Source code in daft/expressions/expressions.py
2460
2461
2462
2463
2464
2465
2466
2467
2468
def list_mean(self) -> Expression:
    """Calculates the mean of each list. If no non-null values in a list, the result is null.

    Tip: See Also
        [`daft.functions.list_mean`](https://docs.daft.ai/en/stable/api/functions/list_mean/)
    """
    from daft.functions import list_mean

    return list_mean(self)

list_min #

list_min() -> Expression

Calculates the minimum of each list. If no non-null values in a list, the result is null.

See Also

daft.functions.list_min

Source code in daft/expressions/expressions.py
2470
2471
2472
2473
2474
2475
2476
2477
2478
def list_min(self) -> Expression:
    """Calculates the minimum of each list. If no non-null values in a list, the result is null.

    Tip: See Also
        [`daft.functions.list_min`](https://docs.daft.ai/en/stable/api/functions/list_min/)
    """
    from daft.functions import list_min

    return list_min(self)

list_sort #

list_sort(desc: bool | Expression | None = None, nulls_first: bool | Expression | None = None) -> Expression

Sorts the inner lists of a list column.

See Also

daft.functions.list_sort

Source code in daft/expressions/expressions.py
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
def list_sort(
    self, desc: bool | Expression | None = None, nulls_first: bool | Expression | None = None
) -> Expression:
    """Sorts the inner lists of a list column.

    Tip: See Also
        [`daft.functions.list_sort`](https://docs.daft.ai/en/stable/api/functions/list_sort/)
    """
    from daft.functions import list_sort

    return list_sort(self, desc, nulls_first)

list_sum #

list_sum() -> Expression

Sums each list. Empty lists and lists with all nulls yield null.

See Also

daft.functions.list_sum

Source code in daft/expressions/expressions.py
2450
2451
2452
2453
2454
2455
2456
2457
2458
def list_sum(self) -> Expression:
    """Sums each list. Empty lists and lists with all nulls yield null.

    Tip: See Also
        [`daft.functions.list_sum`](https://docs.daft.ai/en/stable/api/functions/list_sum/)
    """
    from daft.functions import list_sum

    return list_sum(self)

ln #

ln() -> Expression

The elementwise natural log of a numeric expression.

See Also

daft.functions.ln

Source code in daft/expressions/expressions.py
880
881
882
883
884
885
886
887
888
def ln(self) -> Expression:
    """The elementwise natural log of a numeric expression.

    Tip: See Also
        [`daft.functions.ln`](https://docs.daft.ai/en/stable/api/functions/ln/)
    """
    from daft.functions import ln

    return ln(self)

log #

log(base: int | float = e) -> Expression

The elementwise log with given base, of a numeric expression.

See Also

daft.functions.log

Source code in daft/expressions/expressions.py
870
871
872
873
874
875
876
877
878
def log(self, base: int | builtins.float = math.e) -> Expression:
    """The elementwise log with given base, of a numeric expression.

    Tip: See Also
        [`daft.functions.log`](https://docs.daft.ai/en/stable/api/functions/log/)
    """
    from daft.functions import log

    return log(self, base=base)

log10 #

log10() -> Expression

The elementwise log base 10 of a numeric expression.

See Also

daft.functions.log10

Source code in daft/expressions/expressions.py
860
861
862
863
864
865
866
867
868
def log10(self) -> Expression:
    """The elementwise log base 10 of a numeric expression.

    Tip: See Also
        [`daft.functions.log10`](https://docs.daft.ai/en/stable/api/functions/log10/)
    """
    from daft.functions import log10

    return log10(self)

log1p #

log1p() -> Expression

The ln(self + 1) of a numeric expression.

See Also

daft.functions.log1p

Source code in daft/expressions/expressions.py
890
891
892
893
894
895
896
897
898
def log1p(self) -> Expression:
    """The ln(self + 1) of a numeric expression.

    Tip: See Also
        [`daft.functions.log1p`](https://docs.daft.ai/en/stable/api/functions/log1p/)
    """
    from daft.functions import log1p

    return log1p(self)

log2 #

log2() -> Expression

The elementwise log base 2 of a numeric expression.

See Also

daft.functions.log2

Source code in daft/expressions/expressions.py
850
851
852
853
854
855
856
857
858
def log2(self) -> Expression:
    """The elementwise log base 2 of a numeric expression.

    Tip: See Also
        [`daft.functions.log2`](https://docs.daft.ai/en/stable/api/functions/log2/)
    """
    from daft.functions import log2

    return log2(self)

lower #

lower() -> Expression

Convert UTF-8 string to all lowercase.

See Also

daft.functions.lower

Source code in daft/expressions/expressions.py
2021
2022
2023
2024
2025
2026
2027
2028
2029
def lower(self) -> Expression:
    """Convert UTF-8 string to all lowercase.

    Tip: See Also
        [`daft.functions.lower`](https://docs.daft.ai/en/stable/api/functions/lower/)
    """
    from daft.functions import lower

    return lower(self)

lpad #

lpad(length: int | Expression, pad: str | Expression) -> Expression

Left-pads each string by truncating or padding with the character.

See Also

daft.functions.lpad

Source code in daft/expressions/expressions.py
2191
2192
2193
2194
2195
2196
2197
2198
2199
def lpad(self, length: int | Expression, pad: builtins.str | Expression) -> Expression:
    """Left-pads each string by truncating or padding with the character.

    Tip: See Also
        [`daft.functions.lpad`](https://docs.daft.ai/en/stable/api/functions/lpad/)
    """
    from daft.functions import lpad

    return lpad(self, length, pad)

lstrip #

lstrip() -> Expression

Strip whitespace from the left side of a UTF-8 string.

See Also

daft.functions.lstrip

Source code in daft/expressions/expressions.py
2041
2042
2043
2044
2045
2046
2047
2048
2049
def lstrip(self) -> Expression:
    """Strip whitespace from the left side of a UTF-8 string.

    Tip: See Also
        [`daft.functions.lstrip`](https://docs.daft.ai/en/stable/api/functions/lstrip/)
    """
    from daft.functions import lstrip

    return lstrip(self)

map_get #

map_get(key: Expression) -> Expression

Retrieves the value for a key in a map column.

See Also

daft.functions.map_get

Source code in daft/expressions/expressions.py
2714
2715
2716
2717
2718
2719
2720
2721
2722
def map_get(self, key: Expression) -> Expression:
    """Retrieves the value for a key in a map column.

    Tip: See Also
        [`daft.functions.map_get`](https://docs.daft.ai/en/stable/api/functions/map_get/)
    """
    from daft.functions import map_get

    return map_get(self, key)

map_keys #

map_keys() -> Expression

Returns a list of all keys in the map.

See Also

daft.functions.map_keys

Source code in daft/expressions/expressions.py
2724
2725
2726
2727
2728
2729
2730
2731
2732
def map_keys(self) -> Expression:
    """Returns a list of all keys in the map.

    Tip: See Also
        [`daft.functions.map_keys`](https://docs.daft.ai/en/stable/api/functions/map_keys/)
    """
    from daft.functions import map_keys

    return map_keys(self)

max #

max() -> Expression

Calculates the maximum value in the expression.

See Also

daft.functions.max

Source code in daft/expressions/expressions.py
1126
1127
1128
1129
1130
1131
1132
1133
1134
def max(self) -> Expression:
    """Calculates the maximum value in the expression.

    Tip: See Also
        [`daft.functions.max`](https://docs.daft.ai/en/stable/api/functions/max/)
    """
    from daft.functions import max

    return max(self)

mean #

mean() -> Expression

Calculates the mean of the values in the expression.

See Also

daft.functions.mean

Source code in daft/expressions/expressions.py
1050
1051
1052
1053
1054
1055
1056
1057
1058
def mean(self) -> Expression:
    """Calculates the mean of the values in the expression.

    Tip: See Also
        [`daft.functions.mean`](https://docs.daft.ai/en/stable/api/functions/mean/)
    """
    from daft.functions import mean

    return mean(self)

median #

median() -> Expression

Calculates the median of the values in the expression.

See Also

daft.functions.median

Source code in daft/expressions/expressions.py
1076
1077
1078
1079
1080
1081
1082
1083
1084
def median(self) -> Expression:
    """Calculates the median of the values in the expression.

    Tip: See Also
        [`daft.functions.median`](https://docs.daft.ai/en/stable/api/functions/median/)
    """
    from daft.functions import median

    return median(self)

microsecond #

microsecond() -> Expression

Retrieves the microsecond for a datetime column.

See Also

daft.functions.microsecond

Source code in daft/expressions/expressions.py
1765
1766
1767
1768
1769
1770
1771
1772
1773
def microsecond(self) -> Expression:
    """Retrieves the microsecond for a datetime column.

    Tip: See Also
        [`daft.functions.microsecond`](https://docs.daft.ai/en/stable/api/functions/microsecond/)
    """
    from daft.functions import microsecond

    return microsecond(self)

millisecond #

millisecond() -> Expression

Retrieves the millisecond for a datetime column.

See Also

daft.functions.millisecond

Source code in daft/expressions/expressions.py
1755
1756
1757
1758
1759
1760
1761
1762
1763
def millisecond(self) -> Expression:
    """Retrieves the millisecond for a datetime column.

    Tip: See Also
        [`daft.functions.millisecond`](https://docs.daft.ai/en/stable/api/functions/millisecond/)
    """
    from daft.functions import millisecond

    return millisecond(self)

min #

min() -> Expression

Calculates the minimum value in the expression.

See Also

daft.functions.min

Source code in daft/expressions/expressions.py
1116
1117
1118
1119
1120
1121
1122
1123
1124
def min(self) -> Expression:
    """Calculates the minimum value in the expression.

    Tip: See Also
        [`daft.functions.min`](https://docs.daft.ai/en/stable/api/functions/min/)
    """
    from daft.functions import min

    return min(self)

minhash #

minhash(*, num_hashes: int, ngram_size: int, seed: int = 1, hash_function: Literal['murmurhash3', 'xxhash', 'xxhash32', 'xxhash64', 'xxhash3_64', 'sha1'] = 'murmurhash3') -> Expression

Runs the MinHash algorithm on the series.

See Also

daft.functions.minhash

Source code in daft/expressions/expressions.py
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
def minhash(
    self,
    *,
    num_hashes: int,
    ngram_size: int,
    seed: int = 1,
    hash_function: Literal["murmurhash3", "xxhash", "xxhash32", "xxhash64", "xxhash3_64", "sha1"] = "murmurhash3",
) -> Expression:
    """Runs the MinHash algorithm on the series.

    Tip: See Also
        [`daft.functions.minhash`](https://docs.daft.ai/en/stable/api/functions/minhash/)
    """
    from daft.functions import minhash

    return minhash(self, num_hashes=num_hashes, ngram_size=ngram_size, seed=seed, hash_function=hash_function)

minute #

minute() -> Expression

Retrieves the minute for a datetime column.

See Also

daft.functions.minute

Source code in daft/expressions/expressions.py
1735
1736
1737
1738
1739
1740
1741
1742
1743
def minute(self) -> Expression:
    """Retrieves the minute for a datetime column.

    Tip: See Also
        [`daft.functions.minute`](https://docs.daft.ai/en/stable/api/functions/minute/)
    """
    from daft.functions import minute

    return minute(self)

month #

month() -> Expression

Retrieves the month for a datetime column.

See Also

daft.functions.month

Source code in daft/expressions/expressions.py
1801
1802
1803
1804
1805
1806
1807
1808
1809
def month(self) -> Expression:
    """Retrieves the month for a datetime column.

    Tip: See Also
        [`daft.functions.month`](https://docs.daft.ai/en/stable/api/functions/month/)
    """
    from daft.functions import month

    return month(self)

name #

name() -> str
Source code in daft/expressions/expressions.py
1500
1501
def name(self) -> builtins.str:
    return self._expr.name()

nanosecond #

nanosecond() -> Expression

Retrieves the nanosecond for a datetime column.

See Also

daft.functions.nanosecond

Source code in daft/expressions/expressions.py
1775
1776
1777
1778
1779
1780
1781
1782
1783
def nanosecond(self) -> Expression:
    """Retrieves the nanosecond for a datetime column.

    Tip: See Also
        [`daft.functions.nanosecond`](https://docs.daft.ai/en/stable/api/functions/nanosecond/)
    """
    from daft.functions import nanosecond

    return nanosecond(self)

negate #

negate() -> Expression

The negative of a numeric expression.

See Also

daft.functions.negate

Source code in daft/expressions/expressions.py
630
631
632
633
634
635
636
637
638
def negate(self) -> Expression:
    """The negative of a numeric expression.

    Tip: See Also
        [`daft.functions.negate`](https://docs.daft.ai/en/stable/api/functions/negate/)
    """
    from daft.functions import negate

    return negate(self)

normalize #

normalize(*, remove_punct: bool = False, lowercase: bool = False, nfd_unicode: bool = False, white_space: bool = False) -> Expression

Normalizes a string for more useful deduplication.

See Also

daft.functions.normalize

Source code in daft/expressions/expressions.py
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
def normalize(
    self,
    *,
    remove_punct: bool = False,
    lowercase: bool = False,
    nfd_unicode: bool = False,
    white_space: bool = False,
) -> Expression:
    """Normalizes a string for more useful deduplication.

    Tip: See Also
        [`daft.functions.normalize`](https://docs.daft.ai/en/stable/api/functions/normalize/)
    """
    from daft.functions import normalize

    return normalize(
        self, remove_punct=remove_punct, lowercase=lowercase, nfd_unicode=nfd_unicode, white_space=white_space
    )

not_nan #

not_nan() -> Expression

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

See Also

daft.functions.not_nan

Source code in daft/expressions/expressions.py
2834
2835
2836
2837
2838
2839
2840
2841
2842
def not_nan(self) -> Expression:
    """Checks if values are not NaN (a special float value indicating not-a-number).

    Tip: See Also
        [`daft.functions.not_nan`](https://docs.daft.ai/en/stable/api/functions/not_nan/)
    """
    from daft.functions import not_nan

    return not_nan(self)

not_null #

not_null() -> Expression

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

See Also

daft.functions.not_null

Source code in daft/expressions/expressions.py
1281
1282
1283
1284
1285
1286
1287
1288
1289
def not_null(self) -> Expression:
    """Checks if values in the Expression are not Null (a special value indicating missing data).

    Tip: See Also
        [`daft.functions.not_null`](https://docs.daft.ai/en/stable/api/functions/not_null/)
    """
    from daft.functions import not_null

    return not_null(self)

parse_url #

parse_url() -> Expression

Parse string URLs and extract URL components.

See Also

daft.functions.parse_url

Source code in daft/expressions/expressions.py
1574
1575
1576
1577
1578
1579
1580
1581
1582
def parse_url(self) -> Expression:
    """Parse string URLs and extract URL components.

    Tip: See Also
        [`daft.functions.parse_url`](https://docs.daft.ai/en/stable/api/functions/parse_url/)
    """
    from daft.functions import parse_url

    return parse_url(self)

partition_days #

partition_days() -> Expression

Partitioning Transform that returns the number of days since epoch (1970-01-01).

See Also

daft.functions.partition_days

Source code in daft/expressions/expressions.py
2754
2755
2756
2757
2758
2759
2760
2761
2762
def partition_days(self) -> Expression:
    """Partitioning Transform that returns the number of days since epoch (1970-01-01).

    Tip: See Also
        [`daft.functions.partition_days`](https://docs.daft.ai/en/stable/api/functions/partition_days/)
    """
    from daft.functions import partition_days

    return partition_days(self)

partition_hours #

partition_hours() -> Expression

Partitioning Transform that returns the number of hours since epoch (1970-01-01).

See Also

daft.functions.partition_hours

Source code in daft/expressions/expressions.py
2764
2765
2766
2767
2768
2769
2770
2771
2772
def partition_hours(self) -> Expression:
    """Partitioning Transform that returns the number of hours since epoch (1970-01-01).

    Tip: See Also
        [`daft.functions.partition_hours`](https://docs.daft.ai/en/stable/api/functions/partition_hours/)
    """
    from daft.functions import partition_hours

    return partition_hours(self)

partition_iceberg_bucket #

partition_iceberg_bucket(n: int) -> Expression

Partitioning Transform that returns the Hash Bucket following the Iceberg Specification of murmur3_32_x86.

See Also

daft.functions.partition_iceberg_bucket

Source code in daft/expressions/expressions.py
2794
2795
2796
2797
2798
2799
2800
2801
2802
def partition_iceberg_bucket(self, n: int) -> Expression:
    """Partitioning Transform that returns the Hash Bucket following the Iceberg Specification of murmur3_32_x86.

    Tip: See Also
        [`daft.functions.partition_iceberg_bucket`](https://docs.daft.ai/en/stable/api/functions/partition_iceberg_bucket/)
    """
    from daft.functions import partition_iceberg_bucket

    return partition_iceberg_bucket(self, n)

partition_iceberg_truncate #

partition_iceberg_truncate(w: int) -> Expression

Partitioning Transform that truncates the input to a standard width w following the Iceberg Specification.

See Also

daft.functions.partition_iceberg_truncate

Source code in daft/expressions/expressions.py
2804
2805
2806
2807
2808
2809
2810
2811
2812
def partition_iceberg_truncate(self, w: int) -> Expression:
    """Partitioning Transform that truncates the input to a standard width `w` following the Iceberg Specification.

    Tip: See Also
        [`daft.functions.partition_iceberg_truncate`](https://docs.daft.ai/en/stable/api/functions/partition_iceberg_truncate/)
    """
    from daft.functions import partition_iceberg_truncate

    return partition_iceberg_truncate(self, w)

partition_months #

partition_months() -> Expression

Partitioning Transform that returns the number of months since epoch (1970-01-01).

See Also

daft.functions.partition_months

Source code in daft/expressions/expressions.py
2774
2775
2776
2777
2778
2779
2780
2781
2782
def partition_months(self) -> Expression:
    """Partitioning Transform that returns the number of months since epoch (1970-01-01).

    Tip: See Also
        [`daft.functions.partition_months`](https://docs.daft.ai/en/stable/api/functions/partition_months/)
    """
    from daft.functions import partition_months

    return partition_months(self)

partition_years #

partition_years() -> Expression

Partitioning Transform that returns the number of years since epoch (1970-01-01).

See Also

daft.functions.partition_years

Source code in daft/expressions/expressions.py
2784
2785
2786
2787
2788
2789
2790
2791
2792
def partition_years(self) -> Expression:
    """Partitioning Transform that returns the number of years since epoch (1970-01-01).

    Tip: See Also
        [`daft.functions.partition_years`](https://docs.daft.ai/en/stable/api/functions/partition_years/)
    """
    from daft.functions import partition_years

    return partition_years(self)

pearson_correlation #

pearson_correlation(other: Expression) -> Expression

Compute the Pearson correlation between two embeddings.

See Also

daft.functions.pearson_correlation

Source code in daft/expressions/expressions.py
1638
1639
1640
1641
1642
1643
1644
1645
1646
def pearson_correlation(self, other: Expression) -> Expression:
    """Compute the Pearson correlation between two embeddings.

    Tip: See Also
        [`daft.functions.pearson_correlation`](https://docs.daft.ai/en/stable/api/functions/pearson_correlation/)
    """
    from daft.functions import pearson_correlation

    return pearson_correlation(self, other)

percentile #

percentile(percentage: float) -> Expression

Calculates the exact percentile for a column of numeric values.

See Also

daft.functions.percentile

Source code in daft/expressions/expressions.py
1066
1067
1068
1069
1070
1071
1072
1073
1074
def percentile(self, percentage: builtins.float) -> Expression:
    """Calculates the exact percentile for a column of numeric values.

    Tip: See Also
        [`daft.functions.percentile`](https://docs.daft.ai/en/stable/api/functions/percentile/)
    """
    from daft.functions import percentile

    return percentile(self, percentage)

pow #

pow(exp: Expression) -> Expression

The elementwise exponentiation of a numeric series.

Parameters:

Name Type Description Default
exp Expression

The exponent to raise each element to.

required
Source code in daft/expressions/expressions.py
900
901
902
903
904
905
906
907
908
def pow(self, exp: Expression) -> Expression:
    """The elementwise exponentiation of a numeric series.

    Args:
        exp: The exponent to raise each element to.
    """
    from daft.functions import pow

    return pow(self, exp)

power #

power(exp: Expression) -> Expression

The elementwise exponentiation of a numeric series.

Parameters:

Name Type Description Default
exp Expression

The exponent to raise each element to.

required
Source code in daft/expressions/expressions.py
910
911
912
913
914
915
916
917
918
def power(self, exp: Expression) -> Expression:
    """The elementwise exponentiation of a numeric series.

    Args:
        exp: The exponent to raise each element to.
    """
    from daft.functions import power

    return power(self, exp)

product #

product() -> Expression

Calculates the product of the values in the expression.

See Also

daft.functions.product

Source code in daft/expressions/expressions.py
1020
1021
1022
1023
1024
1025
1026
1027
1028
def product(self) -> Expression:
    """Calculates the product of the values in the expression.

    Tip: See Also
        [`daft.functions.product`](https://docs.daft.ai/en/stable/api/functions/product/)
    """
    from daft.functions import product

    return product(self)

quarter #

quarter() -> Expression

Retrieves the quarter for a datetime column.

See Also

daft.functions.quarter

Source code in daft/expressions/expressions.py
1811
1812
1813
1814
1815
1816
1817
1818
1819
def quarter(self) -> Expression:
    """Retrieves the quarter for a datetime column.

    Tip: See Also
        [`daft.functions.quarter`](https://docs.daft.ai/en/stable/api/functions/quarter/)
    """
    from daft.functions import quarter

    return quarter(self)

radians #

radians() -> Expression

The elementwise radians of a numeric expression.

See Also

daft.functions.radians

Source code in daft/expressions/expressions.py
830
831
832
833
834
835
836
837
838
def radians(self) -> Expression:
    """The elementwise radians of a numeric expression.

    Tip: See Also
        [`daft.functions.radians`](https://docs.daft.ai/en/stable/api/functions/radians/)
    """
    from daft.functions import radians

    return radians(self)

regexp #

regexp(pattern: str | Expression) -> Expression

Check whether each string matches the given regular expression pattern in a string column.

See Also

daft.functions.regexp

Source code in daft/expressions/expressions.py
2606
2607
2608
2609
2610
2611
2612
2613
2614
def regexp(self, pattern: builtins.str | Expression) -> Expression:
    """Check whether each string matches the given regular expression pattern in a string column.

    Tip: See Also
        [`daft.functions.regexp`](https://docs.daft.ai/en/stable/api/functions/regexp/)
    """
    from daft.functions import regexp

    return regexp(self, pattern)

regexp_count #

regexp_count(pattern: str | Expression) -> Expression

Counts the number of times a regex pattern appears in a string.

See Also

daft.functions.regexp_count

Source code in daft/expressions/expressions.py
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
def regexp_count(
    self,
    pattern: builtins.str | Expression,
) -> Expression:
    """Counts the number of times a regex pattern appears in a string.

    Tip: See Also
        [`daft.functions.regexp_count`](https://docs.daft.ai/en/stable/api/functions/regexp_count/)
    """
    from daft.functions import regexp_count

    return regexp_count(self, pattern)

regexp_extract #

regexp_extract(pattern: str | Expression, index: int = 0) -> Expression

Extracts the specified match group from the first regex match in each string in a string column.

See Also

daft.functions.regexp_extract

Source code in daft/expressions/expressions.py
2616
2617
2618
2619
2620
2621
2622
2623
2624
def regexp_extract(self, pattern: builtins.str | Expression, index: int = 0) -> Expression:
    """Extracts the specified match group from the first regex match in each string in a string column.

    Tip: See Also
        [`daft.functions.regexp_extract`](https://docs.daft.ai/en/stable/api/functions/regexp_extract/)
    """
    from daft.functions import regexp_extract

    return regexp_extract(self, pattern, index=index)

regexp_extract_all #

regexp_extract_all(pattern: str | Expression, index: int = 0) -> Expression

Extracts the specified match group from all regex matches in each string in a string column.

See Also

daft.functions.regexp_extract_all

Source code in daft/expressions/expressions.py
2626
2627
2628
2629
2630
2631
2632
2633
2634
def regexp_extract_all(self, pattern: builtins.str | Expression, index: int = 0) -> Expression:
    r"""Extracts the specified match group from all regex matches in each string in a string column.

    Tip: See Also
        [`daft.functions.regexp_extract_all`](https://docs.daft.ai/en/stable/api/functions/regexp_extract_all/)
    """
    from daft.functions import regexp_extract_all

    return regexp_extract_all(self, pattern, index=index)

regexp_replace #

regexp_replace(pattern: str | Expression, replacement: str | Expression) -> Expression

Replaces all occurrences of a regex pattern in a string column with a replacement string.

See Also

daft.functions.regexp_replace

Source code in daft/expressions/expressions.py
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
def regexp_replace(
    self,
    pattern: builtins.str | Expression,
    replacement: builtins.str | Expression,
) -> Expression:
    """Replaces all occurrences of a regex pattern in a string column with a replacement string.

    Tip: See Also
        [`daft.functions.regexp_replace`](https://docs.daft.ai/en/stable/api/functions/regexp_replace/)
    """
    from daft.functions import regexp_replace

    return regexp_replace(self, pattern, replacement)

regexp_split #

regexp_split(pattern: str | Expression) -> Expression

Splits each string on the given regex pattern, into a list of strings.

See Also

daft.functions.regexp_split

Source code in daft/expressions/expressions.py
2011
2012
2013
2014
2015
2016
2017
2018
2019
def regexp_split(self, pattern: builtins.str | Expression) -> Expression:
    """Splits each string on the given regex pattern, into a list of strings.

    Tip: See Also
        [`daft.functions.regexp_split`](https://docs.daft.ai/en/stable/api/functions/regexp_split/)
    """
    from daft.functions import regexp_split

    return regexp_split(self, pattern)

repeat #

repeat(n: int | Expression) -> Expression

Repeats each string n times.

See Also

daft.functions.repeat

Source code in daft/expressions/expressions.py
2201
2202
2203
2204
2205
2206
2207
2208
2209
def repeat(self, n: int | Expression) -> Expression:
    """Repeats each string n times.

    Tip: See Also
        [`daft.functions.repeat`](https://docs.daft.ai/en/stable/api/functions/repeat/)
    """
    from daft.functions import repeat

    return repeat(self, n)

replace #

replace(search: str | Expression, replacement: str | Expression) -> Expression

Replaces all occurrences of a substring in a string with a replacement string.

See Also

daft.functions.replace

Source code in daft/expressions/expressions.py
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
def replace(
    self,
    search: builtins.str | Expression,
    replacement: builtins.str | Expression,
) -> Expression:
    """Replaces all occurrences of a substring in a string with a replacement string.

    Tip: See Also
        [`daft.functions.replace`](https://docs.daft.ai/en/stable/api/functions/replace/)
    """
    from daft.functions import replace

    return replace(self, search, replacement)

replace_time_zone #

replace_time_zone(timezone: str | None = None) -> Expression

Replaces the timezone of a timestamp while preserving the local time.

See Also

daft.functions.replace_time_zone

Source code in daft/expressions/expressions.py
1981
1982
1983
1984
1985
1986
1987
1988
1989
def replace_time_zone(self, timezone: builtins.str | None = None) -> Expression:
    """Replaces the timezone of a timestamp while preserving the local time.

    Tip: See Also
        [`daft.functions.replace_time_zone`](https://docs.daft.ai/en/stable/api/functions/replace_time_zone/)
    """
    from daft.functions import replace_time_zone

    return replace_time_zone(self, timezone)

resize #

resize(w: int, h: int) -> Expression

Resize image into the provided width and height.

See Also

daft.functions.resize

Source code in daft/expressions/expressions.py
2397
2398
2399
2400
2401
2402
2403
2404
2405
def resize(self, w: int, h: int) -> Expression:
    """Resize image into the provided width and height.

    Tip: See Also
        [`daft.functions.resize`](https://docs.daft.ai/en/stable/api/functions/resize/)
    """
    from daft.functions import resize

    return resize(self, w, h)

reverse #

reverse() -> Expression

Reverse a UTF-8 string.

See Also

daft.functions.reverse

Source code in daft/expressions/expressions.py
2071
2072
2073
2074
2075
2076
2077
2078
2079
def reverse(self) -> Expression:
    """Reverse a UTF-8 string.

    Tip: See Also
        [`daft.functions.reverse`](https://docs.daft.ai/en/stable/api/functions/reverse/)
    """
    from daft.functions import reverse

    return reverse(self)

right #

right(nchars: int | Expression) -> Expression

Gets the n (from nchars) right-most characters of each string.

See Also

daft.functions.right

Source code in daft/expressions/expressions.py
2171
2172
2173
2174
2175
2176
2177
2178
2179
def right(self, nchars: int | Expression) -> Expression:
    """Gets the n (from nchars) right-most characters of each string.

    Tip: See Also
        [`daft.functions.right`](https://docs.daft.ai/en/stable/api/functions/right/)
    """
    from daft.functions import right

    return right(self, nchars)

round #

round(decimals: Expression | int = 0) -> Expression

The round of a numeric expression.

See Also

daft.functions.round

Source code in daft/expressions/expressions.py
640
641
642
643
644
645
646
647
648
def round(self, decimals: Expression | int = 0) -> Expression:
    """The round of a numeric expression.

    Tip: See Also
        [`daft.functions.round`](https://docs.daft.ai/en/stable/api/functions/round/)
    """
    from daft.functions import round

    return round(self, decimals)

rpad #

rpad(length: int | Expression, pad: str | Expression) -> Expression

Right-pads each string by truncating or padding with the character.

See Also

daft.functions.rpad

Source code in daft/expressions/expressions.py
2181
2182
2183
2184
2185
2186
2187
2188
2189
def rpad(self, length: int | Expression, pad: builtins.str | Expression) -> Expression:
    """Right-pads each string by truncating or padding with the character.

    Tip: See Also
        [`daft.functions.rpad`](https://docs.daft.ai/en/stable/api/functions/rpad/)
    """
    from daft.functions import rpad

    return rpad(self, length, pad)

rstrip #

rstrip() -> Expression

Strip whitespace from the right side of a UTF-8 string.

See Also

daft.functions.rstrip

Source code in daft/expressions/expressions.py
2051
2052
2053
2054
2055
2056
2057
2058
2059
def rstrip(self) -> Expression:
    """Strip whitespace from the right side of a UTF-8 string.

    Tip: See Also
        [`daft.functions.rstrip`](https://docs.daft.ai/en/stable/api/functions/rstrip/)
    """
    from daft.functions import rstrip

    return rstrip(self)

sec #

sec() -> Expression

The elementwise secant of a numeric expression.

See Also

daft.functions.sec

Source code in daft/expressions/expressions.py
710
711
712
713
714
715
716
717
718
def sec(self) -> Expression:
    """The elementwise secant of a numeric expression.

    Tip: See Also
        [`daft.functions.sec`](https://docs.daft.ai/en/stable/api/functions/sec/)
    """
    from daft.functions import sec

    return sec(self)

second #

second() -> Expression

Retrieves the second for a datetime column.

See Also

daft.functions.second

Source code in daft/expressions/expressions.py
1745
1746
1747
1748
1749
1750
1751
1752
1753
def second(self) -> Expression:
    """Retrieves the second for a datetime column.

    Tip: See Also
        [`daft.functions.second`](https://docs.daft.ai/en/stable/api/functions/second/)
    """
    from daft.functions import second

    return second(self)

serialize #

serialize(format: Literal['json']) -> Expression

Serializes the expression as a string using the specified format.

See Also

daft.functions.serialize

Source code in daft/expressions/expressions.py
1480
1481
1482
1483
1484
1485
1486
1487
1488
def serialize(self, format: Literal["json"]) -> Expression:
    """Serializes the expression as a string using the specified format.

    Tip: See Also
        [`daft.functions.serialize`](https://docs.daft.ai/en/stable/api/functions/serialize/)
    """
    from daft.functions import serialize

    return serialize(self, format=format)

shift_left #

shift_left(other: Expression) -> Expression

Shifts the bits of an integer expression to the left (expr << other).

See Also

daft.functions.shift_left

Source code in daft/expressions/expressions.py
970
971
972
973
974
975
976
977
978
def shift_left(self, other: Expression) -> Expression:
    """Shifts the bits of an integer expression to the left (``expr << other``).

    Tip: See Also
        [`daft.functions.shift_left`](https://docs.daft.ai/en/stable/api/functions/shift_left/)
    """
    from daft.functions import shift_left

    return shift_left(self, other)

shift_right #

shift_right(other: Expression) -> Expression

Shifts the bits of an integer expression to the right (expr >> other).

See Also

daft.functions.shift_right

Source code in daft/expressions/expressions.py
980
981
982
983
984
985
986
987
988
def shift_right(self, other: Expression) -> Expression:
    """Shifts the bits of an integer expression to the right (``expr >> other``).

    Tip: See Also
        [`daft.functions.shift_right`](https://docs.daft.ai/en/stable/api/functions/shift_right/)
    """
    from daft.functions import shift_right

    return shift_right(self, other)

sign #

sign() -> Expression

The sign of a numeric expression.

See Also

daft.functions.sign

Source code in daft/expressions/expressions.py
620
621
622
623
624
625
626
627
628
def sign(self) -> Expression:
    """The sign of a numeric expression.

    Tip: See Also
        [`daft.functions.sign`](https://docs.daft.ai/en/stable/api/functions/sign/)
    """
    from daft.functions import sign

    return sign(self)

simhash #

simhash(*, ngram_size: int = 3, hash_function: Literal['murmurhash3', 'xxhash', 'xxhash32', 'xxhash64', 'xxhash3_64', 'sha1'] = 'xxhash3_64') -> Expression

Compute a SimHash fingerprint of this string expression.

See Also

daft.functions.simhash

Source code in daft/expressions/expressions.py
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
def simhash(
    self,
    *,
    ngram_size: int = 3,
    hash_function: Literal["murmurhash3", "xxhash", "xxhash32", "xxhash64", "xxhash3_64", "sha1"] = "xxhash3_64",
) -> Expression:
    """Compute a SimHash fingerprint of this string expression.

    Tip: See Also
        [`daft.functions.simhash`](https://docs.daft.ai/en/stable/api/functions/simhash/)
    """
    from daft.functions import simhash

    return simhash(self, ngram_size=ngram_size, hash_function=hash_function)

sin #

sin() -> Expression

The elementwise sine of a numeric expression.

See Also

daft.functions.sin

Source code in daft/expressions/expressions.py
670
671
672
673
674
675
676
677
678
def sin(self) -> Expression:
    """The elementwise sine of a numeric expression.

    Tip: See Also
        [`daft.functions.sin`](https://docs.daft.ai/en/stable/api/functions/sin/)
    """
    from daft.functions import sin

    return sin(self)

sinh #

sinh() -> Expression

The elementwise hyperbolic sine of a numeric expression.

See Also

daft.functions.sinh

Source code in daft/expressions/expressions.py
730
731
732
733
734
735
736
737
738
def sinh(self) -> Expression:
    """The elementwise hyperbolic sine of a numeric expression.

    Tip: See Also
        [`daft.functions.sinh`](https://docs.daft.ai/en/stable/api/functions/sinh/)
    """
    from daft.functions import sinh

    return sinh(self)

skew #

skew() -> Expression

Calculates the skewness of the values from the expression.

See Also

daft.functions.skew

Source code in daft/expressions/expressions.py
1166
1167
1168
1169
1170
1171
1172
1173
1174
def skew(self) -> Expression:
    """Calculates the skewness of the values from the expression.

    Tip: See Also
        [`daft.functions.skew`](https://docs.daft.ai/en/stable/api/functions/skew/)
    """
    from daft.functions import skew

    return skew(self)

slice #

slice(start: int | Expression, end: int | Expression | None = None) -> Expression

Get a subset of each list or binary value.

See Also

daft.functions.slice

Source code in daft/expressions/expressions.py
2734
2735
2736
2737
2738
2739
2740
2741
2742
def slice(self, start: int | Expression, end: int | Expression | None = None) -> Expression:
    """Get a subset of each list or binary value.

    Tip: See Also
        [`daft.functions.slice`](https://docs.daft.ai/en/stable/api/functions/slice/)
    """
    from daft.functions import slice

    return slice(self, start, end)

split #

split(split_on: str | Expression) -> Expression

Splits each string on the given string, into a list of strings.

See Also

daft.functions.split

Source code in daft/expressions/expressions.py
2001
2002
2003
2004
2005
2006
2007
2008
2009
def split(self, split_on: builtins.str | Expression) -> Expression:
    """Splits each string on the given string, into a list of strings.

    Tip: See Also
        [`daft.functions.split`](https://docs.daft.ai/en/stable/api/functions/split/)
    """
    from daft.functions import split

    return split(self, split_on)

sqrt #

sqrt() -> Expression

The square root of a numeric expression.

See Also

daft.functions.sqrt

Source code in daft/expressions/expressions.py
650
651
652
653
654
655
656
657
658
def sqrt(self) -> Expression:
    """The square root of a numeric expression.

    Tip: See Also
        [`daft.functions.sqrt`](https://docs.daft.ai/en/stable/api/functions/sqrt/)
    """
    from daft.functions import sqrt

    return sqrt(self)

startswith #

startswith(prefix: str | Expression) -> Expression

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

See Also

daft.functions.startswith

Source code in daft/expressions/expressions.py
2251
2252
2253
2254
2255
2256
2257
2258
2259
def startswith(self, prefix: builtins.str | Expression) -> Expression:
    """Checks whether each string starts with the given pattern in a string column.

    Tip: See Also
        [`daft.functions.startswith`](https://docs.daft.ai/en/stable/api/functions/startswith/)
    """
    from daft.functions import startswith

    return startswith(self, prefix)

stddev #

stddev(ddof: int = 1) -> Expression

Calculates the standard deviation of the values in the expression.

Parameters:

Name Type Description Default
ddof int

Delta degrees of freedom. The divisor used in calculations is N - ddof, where N is the number of non-null elements. Defaults to 1 (sample standard deviation).

1
See Also

daft.functions.stddev

Source code in daft/expressions/expressions.py
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
def stddev(self, ddof: int = 1) -> Expression:
    """Calculates the standard deviation of the values in the expression.

    Args:
        ddof: Delta degrees of freedom. The divisor used in calculations
            is N - ddof, where N is the number of non-null elements.
            Defaults to 1 (sample standard deviation).

    Tip: See Also
        [`daft.functions.stddev`](https://docs.daft.ai/en/stable/api/functions/stddev/)
    """
    from daft.functions import stddev

    return stddev(self, ddof)

strftime #

strftime(format: str | None = None) -> Expression

Converts a datetime/date column to a string column.

See Also

daft.functions.strftime

Source code in daft/expressions/expressions.py
1871
1872
1873
1874
1875
1876
1877
1878
1879
def strftime(self, format: builtins.str | None = None) -> Expression:
    """Converts a datetime/date column to a string column.

    Tip: See Also
        [`daft.functions.strftime`](https://docs.daft.ai/en/stable/api/functions/strftime/)
    """
    from daft.functions import strftime

    return strftime(self, format)

string_agg #

string_agg(delimiter: str | None = None) -> Expression

Aggregates the values in the expression into a single string by concatenating them.

Parameters:

Name Type Description Default
delimiter str | None

Optional delimiter to insert between concatenated values. Only supported for string columns.

None
See Also

daft.functions.string_agg

Source code in daft/expressions/expressions.py
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
def string_agg(self, delimiter: str | None = None) -> Expression:
    """Aggregates the values in the expression into a single string by concatenating them.

    Args:
        delimiter: Optional delimiter to insert between concatenated values. Only supported for string columns.

    Tip: See Also
        [`daft.functions.string_agg`](https://docs.daft.ai/en/stable/api/functions/string_agg/)
    """
    from daft.functions import string_agg

    return string_agg(self, delimiter=delimiter)

strip #

strip() -> Expression

Strip whitespace from both sides of a UTF-8 string.

See Also

daft.functions.strip

Source code in daft/expressions/expressions.py
2061
2062
2063
2064
2065
2066
2067
2068
2069
def strip(self) -> Expression:
    """Strip whitespace from both sides of a UTF-8 string.

    Tip: See Also
        [`daft.functions.strip`](https://docs.daft.ai/en/stable/api/functions/strip/)
    """
    from daft.functions import strip

    return strip(self)

substr #

substr(start: int | Expression, length: int | Expression | None = None) -> Expression

Extract a substring from a string, starting at a specified index and extending for a given length.

See Also

daft.functions.substr

Source code in daft/expressions/expressions.py
2231
2232
2233
2234
2235
2236
2237
2238
2239
def substr(self, start: int | Expression, length: int | Expression | None = None) -> Expression:
    """Extract a substring from a string, starting at a specified index and extending for a given length.

    Tip: See Also
        [`daft.functions.substr`](https://docs.daft.ai/en/stable/api/functions/substr/)
    """
    from daft.functions import substr

    return substr(self, start, length)

sum #

sum() -> Expression

Calculates the sum of the values in the expression.

See Also

daft.functions.sum

Source code in daft/expressions/expressions.py
1010
1011
1012
1013
1014
1015
1016
1017
1018
def sum(self) -> Expression:
    """Calculates the sum of the values in the expression.

    Tip: See Also
        [`daft.functions.sum`](https://docs.daft.ai/en/stable/api/functions/sum/)
    """
    from daft.functions import sum

    return sum(self)

tan #

tan() -> Expression

The elementwise tangent of a numeric expression.

See Also

daft.functions.tan

Source code in daft/expressions/expressions.py
690
691
692
693
694
695
696
697
698
def tan(self) -> Expression:
    """The elementwise tangent of a numeric expression.

    Tip: See Also
        [`daft.functions.tan`](https://docs.daft.ai/en/stable/api/functions/tan/)
    """
    from daft.functions import tan

    return tan(self)

tanh #

tanh() -> Expression

The elementwise hyperbolic tangent of a numeric expression.

See Also

daft.functions.tanh

Source code in daft/expressions/expressions.py
750
751
752
753
754
755
756
757
758
def tanh(self) -> Expression:
    """The elementwise hyperbolic tangent of a numeric expression.

    Tip: See Also
        [`daft.functions.tanh`](https://docs.daft.ai/en/stable/api/functions/tanh/)
    """
    from daft.functions import tanh

    return tanh(self)

time #

time() -> Expression

Retrieves the time for a datetime column.

Source code in daft/expressions/expressions.py
1795
1796
1797
1798
1799
def time(self) -> Expression:
    """Retrieves the time for a datetime column."""
    from daft.functions import time

    return time(self)

to_arrow_expr #

to_arrow_expr() -> Expression

Returns this expression as a pyarrow.compute.Expression for integrations with other systems.

Source code in daft/expressions/expressions.py
166
167
168
169
170
def to_arrow_expr(self) -> pc.Expression:
    """Returns this expression as a pyarrow.compute.Expression for integrations with other systems."""
    from daft.expressions.pyarrow_visitor import _PyArrowExpressionVisitor

    return _PyArrowExpressionVisitor().visit(self)

to_camel_case #

to_camel_case() -> Expression

Convert a string to lower camel case.

See Also

daft.functions.to_camel_case

Source code in daft/expressions/expressions.py
2091
2092
2093
2094
2095
2096
2097
2098
2099
def to_camel_case(self) -> Expression:
    """Convert a string to lower camel case.

    Tip: See Also
        [`daft.functions.to_camel_case`](https://docs.daft.ai/en/stable/api/functions/to_camel_case/)
    """
    from daft.functions import to_camel_case

    return to_camel_case(self)

to_date #

to_date(format: str) -> Expression

Converts a string to a date using the specified format.

See Also

daft.functions.to_date

Source code in daft/expressions/expressions.py
1951
1952
1953
1954
1955
1956
1957
1958
1959
def to_date(self, format: builtins.str) -> Expression:
    """Converts a string to a date using the specified format.

    Tip: See Also
        [`daft.functions.to_date`](https://docs.daft.ai/en/stable/api/functions/to_date/)
    """
    from daft.functions import to_date

    return to_date(self, format)

to_datetime #

to_datetime(format: str, timezone: str | None = None) -> Expression

Converts a string to a datetime using the specified format and timezone.

See Also

daft.functions.to_datetime

Source code in daft/expressions/expressions.py
1961
1962
1963
1964
1965
1966
1967
1968
1969
def to_datetime(self, format: builtins.str, timezone: builtins.str | None = None) -> Expression:
    """Converts a string to a datetime using the specified format and timezone.

    Tip: See Also
        [`daft.functions.to_datetime`](https://docs.daft.ai/en/stable/api/functions/to_datetime/)
    """
    from daft.functions import to_datetime

    return to_datetime(self, format, timezone)

to_kebab_case #

to_kebab_case() -> Expression

Convert a string to kebab case.

See Also

daft.functions.to_kebab_case

Source code in daft/expressions/expressions.py
2131
2132
2133
2134
2135
2136
2137
2138
2139
def to_kebab_case(self) -> Expression:
    """Convert a string to kebab case.

    Tip: See Also
        [`daft.functions.to_kebab_case`](https://docs.daft.ai/en/stable/api/functions/to_kebab_case/)
    """
    from daft.functions import to_kebab_case

    return to_kebab_case(self)

to_snake_case #

to_snake_case() -> Expression

Convert a string to snake case.

See Also

daft.functions.to_snake_case

Source code in daft/expressions/expressions.py
2111
2112
2113
2114
2115
2116
2117
2118
2119
def to_snake_case(self) -> Expression:
    """Convert a string to snake case.

    Tip: See Also
        [`daft.functions.to_snake_case`](https://docs.daft.ai/en/stable/api/functions/to_snake_case/)
    """
    from daft.functions import to_snake_case

    return to_snake_case(self)

to_title_case #

to_title_case() -> Expression

Convert a string to title case.

See Also

daft.functions.to_title_case

Source code in daft/expressions/expressions.py
2151
2152
2153
2154
2155
2156
2157
2158
2159
def to_title_case(self) -> Expression:
    """Convert a string to title case.

    Tip: See Also
        [`daft.functions.to_title_case`](https://docs.daft.ai/en/stable/api/functions/to_title_case/)
    """
    from daft.functions import to_title_case

    return to_title_case(self)

to_unix_epoch #

to_unix_epoch(time_unit: str | TimeUnit | None = None) -> Expression

Converts a datetime column to a Unix timestamp with the specified time unit. (default: seconds).

See Also

daft.functions.to_unix_epoch

Source code in daft/expressions/expressions.py
2744
2745
2746
2747
2748
2749
2750
2751
2752
def to_unix_epoch(self, time_unit: builtins.str | TimeUnit | None = None) -> Expression:
    """Converts a datetime column to a Unix timestamp with the specified time unit. (default: seconds).

    Tip: See Also
        [`daft.functions.to_unix_epoch`](https://docs.daft.ai/en/stable/api/functions/to_unix_epoch/)
    """
    from daft.functions import to_unix_epoch

    return to_unix_epoch(self, time_unit=time_unit)

to_upper_camel_case #

to_upper_camel_case() -> Expression

Convert a string to upper camel case.

See Also

daft.functions.to_upper_camel_case

Source code in daft/expressions/expressions.py
2101
2102
2103
2104
2105
2106
2107
2108
2109
def to_upper_camel_case(self) -> Expression:
    """Convert a string to upper camel case.

    Tip: See Also
        [`daft.functions.to_upper_camel_case`](https://docs.daft.ai/en/stable/api/functions/to_upper_camel_case/)
    """
    from daft.functions import to_upper_camel_case

    return to_upper_camel_case(self)

to_upper_kebab_case #

to_upper_kebab_case() -> Expression

Convert a string to upper kebab case.

See Also

daft.functions.to_upper_kebab_case

Source code in daft/expressions/expressions.py
2141
2142
2143
2144
2145
2146
2147
2148
2149
def to_upper_kebab_case(self) -> Expression:
    """Convert a string to upper kebab case.

    Tip: See Also
        [`daft.functions.to_upper_kebab_case`](https://docs.daft.ai/en/stable/api/functions/to_upper_kebab_case/)
    """
    from daft.functions import to_upper_kebab_case

    return to_upper_kebab_case(self)

to_upper_snake_case #

to_upper_snake_case() -> Expression

Convert a string to upper snake case.

See Also

daft.functions.to_upper_snake_case

Source code in daft/expressions/expressions.py
2121
2122
2123
2124
2125
2126
2127
2128
2129
def to_upper_snake_case(self) -> Expression:
    """Convert a string to upper snake case.

    Tip: See Also
        [`daft.functions.to_upper_snake_case`](https://docs.daft.ai/en/stable/api/functions/to_upper_snake_case/)
    """
    from daft.functions import to_upper_snake_case

    return to_upper_snake_case(self)

tokenize_decode #

tokenize_decode(tokens_path: str, *, io_config: IOConfig | None = None, pattern: str | None = None, special_tokens: str | None = None) -> Expression

Decodes each list of integer tokens into a string using a tokenizer.

See Also

daft.functions.tokenize_decode

Source code in daft/expressions/expressions.py
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
def tokenize_decode(
    self,
    tokens_path: builtins.str,
    *,
    io_config: IOConfig | None = None,
    pattern: builtins.str | None = None,
    special_tokens: builtins.str | None = None,
) -> Expression:
    """Decodes each list of integer tokens into a string using a tokenizer.

    Tip: See Also
        [`daft.functions.tokenize_decode`](https://docs.daft.ai/en/stable/api/functions/tokenize_decode/)
    """
    from daft.functions import tokenize_decode

    return tokenize_decode(
        self,
        tokens_path,
        io_config=io_config,
        pattern=pattern,
        special_tokens=special_tokens,
    )

tokenize_encode #

tokenize_encode(tokens_path: str, *, io_config: IOConfig | None = None, pattern: str | None = None, special_tokens: str | None = None, use_special_tokens: bool | None = None) -> Expression

Encodes each string as a list of integer tokens using a tokenizer.

See Also

daft.functions.tokenize_encode

Source code in daft/expressions/expressions.py
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
def tokenize_encode(
    self,
    tokens_path: builtins.str,
    *,
    io_config: IOConfig | None = None,
    pattern: builtins.str | None = None,
    special_tokens: builtins.str | None = None,
    use_special_tokens: bool | None = None,
) -> Expression:
    """Encodes each string as a list of integer tokens using a tokenizer.

    Tip: See Also
        [`daft.functions.tokenize_encode`](https://docs.daft.ai/en/stable/api/functions/tokenize_encode/)
    """
    from daft.functions import tokenize_encode

    return tokenize_encode(
        self,
        tokens_path,
        io_config=io_config,
        pattern=pattern,
        special_tokens=special_tokens,
        use_special_tokens=use_special_tokens,
    )

total_days #

total_days() -> Expression

Calculates the total number of days for a duration column.

See Also

daft.functions.total_days

Source code in daft/expressions/expressions.py
1941
1942
1943
1944
1945
1946
1947
1948
1949
def total_days(self) -> Expression:
    """Calculates the total number of days for a duration column.

    Tip: See Also
        [`daft.functions.total_days`](https://docs.daft.ai/en/stable/api/functions/total_days/)
    """
    from daft.functions import total_days

    return total_days(self)

total_hours #

total_hours() -> Expression

Calculates the total number of hours for a duration column.

See Also

daft.functions.total_hours

Source code in daft/expressions/expressions.py
1931
1932
1933
1934
1935
1936
1937
1938
1939
def total_hours(self) -> Expression:
    """Calculates the total number of hours for a duration column.

    Tip: See Also
        [`daft.functions.total_hours`](https://docs.daft.ai/en/stable/api/functions/total_hours/)
    """
    from daft.functions import total_hours

    return total_hours(self)

total_microseconds #

total_microseconds() -> Expression

Calculates the total number of microseconds for a duration column.

See Also

daft.functions.total_microseconds

Source code in daft/expressions/expressions.py
1901
1902
1903
1904
1905
1906
1907
1908
1909
def total_microseconds(self) -> Expression:
    """Calculates the total number of microseconds for a duration column.

    Tip: See Also
        [`daft.functions.total_microseconds`](https://docs.daft.ai/en/stable/api/functions/total_microseconds/)
    """
    from daft.functions import total_microseconds

    return total_microseconds(self)

total_milliseconds #

total_milliseconds() -> Expression

Calculates the total number of milliseconds for a duration column.

See Also

daft.functions.total_milliseconds

Source code in daft/expressions/expressions.py
1891
1892
1893
1894
1895
1896
1897
1898
1899
def total_milliseconds(self) -> Expression:
    """Calculates the total number of milliseconds for a duration column.

    Tip: See Also
        [`daft.functions.total_milliseconds`](https://docs.daft.ai/en/stable/api/functions/total_milliseconds/)
    """
    from daft.functions import total_milliseconds

    return total_milliseconds(self)

total_minutes #

total_minutes() -> Expression

Calculates the total number of minutes for a duration column.

See Also

daft.functions.total_minutes

Source code in daft/expressions/expressions.py
1921
1922
1923
1924
1925
1926
1927
1928
1929
def total_minutes(self) -> Expression:
    """Calculates the total number of minutes for a duration column.

    Tip: See Also
        [`daft.functions.total_minutes`](https://docs.daft.ai/en/stable/api/functions/total_minutes/)
    """
    from daft.functions import total_minutes

    return total_minutes(self)

total_nanoseconds #

total_nanoseconds() -> Expression

Calculates the total number of nanoseconds for a duration column.

See Also

daft.functions.total_nanoseconds

Source code in daft/expressions/expressions.py
1911
1912
1913
1914
1915
1916
1917
1918
1919
def total_nanoseconds(self) -> Expression:
    """Calculates the total number of nanoseconds for a duration column.

    Tip: See Also
        [`daft.functions.total_nanoseconds`](https://docs.daft.ai/en/stable/api/functions/total_nanoseconds/)
    """
    from daft.functions import total_nanoseconds

    return total_nanoseconds(self)

total_seconds #

total_seconds() -> Expression

Calculates the total number of seconds for a duration column.

See Also

daft.functions.total_seconds

Source code in daft/expressions/expressions.py
1881
1882
1883
1884
1885
1886
1887
1888
1889
def total_seconds(self) -> Expression:
    """Calculates the total number of seconds for a duration column.

    Tip: See Also
        [`daft.functions.total_seconds`](https://docs.daft.ai/en/stable/api/functions/total_seconds/)
    """
    from daft.functions import total_seconds

    return total_seconds(self)

try_cast #

try_cast(dtype: DataTypeLike) -> Expression

Attempts to cast an expression to the given datatype, returning null on failure.

Unlike cast, this method does not raise an error when the conversion fails. Instead, it returns null for values that cannot be converted.

See Also

daft.functions.try_cast

Source code in daft/expressions/expressions.py
500
501
502
503
504
505
506
507
508
509
510
511
def try_cast(self, dtype: DataTypeLike) -> Expression:
    """Attempts to cast an expression to the given datatype, returning null on failure.

    Unlike `cast`, this method does not raise an error when the conversion fails.
    Instead, it returns null for values that cannot be converted.

    Tip: See Also
        [`daft.functions.try_cast`](https://docs.daft.ai/en/stable/api/functions/try_cast/)
    """
    from daft.functions import try_cast

    return try_cast(self, dtype)

try_compress #

try_compress(codec: COMPRESSION_CODEC) -> Expression

Compress or null if unsuccessful.

See Also

daft.functions.try_compress

Source code in daft/expressions/expressions.py
1440
1441
1442
1443
1444
1445
1446
1447
1448
def try_compress(self, codec: COMPRESSION_CODEC) -> Expression:
    """Compress or null if unsuccessful.

    Tip: See Also
        [`daft.functions.try_compress`](https://docs.daft.ai/en/stable/api/functions/try_compress/)
    """
    from daft.functions import try_compress

    return try_compress(self, codec=codec)

try_decode #

try_decode(charset: ENCODING_CHARSET) -> Expression

Decode or null if unsuccessful.

See Also

daft.functions.try_decode

Source code in daft/expressions/expressions.py
1410
1411
1412
1413
1414
1415
1416
1417
1418
def try_decode(self, charset: ENCODING_CHARSET) -> Expression:
    """Decode or null if unsuccessful.

    Tip: See Also
        [`daft.functions.try_decode`](https://docs.daft.ai/en/stable/api/functions/try_decode/)
    """
    from daft.functions import try_decode

    return try_decode(self, charset=charset)

try_decompress #

try_decompress(codec: COMPRESSION_CODEC) -> Expression

Decompress or null if unsuccessful.

See Also

daft.functions.try_decompress

Source code in daft/expressions/expressions.py
1450
1451
1452
1453
1454
1455
1456
1457
1458
def try_decompress(self, codec: COMPRESSION_CODEC) -> Expression:
    """Decompress or null if unsuccessful.

    Tip: See Also
        [`daft.functions.try_decompress`](https://docs.daft.ai/en/stable/api/functions/try_decompress/)
    """
    from daft.functions import try_decompress

    return try_decompress(self, codec=codec)

try_deserialize #

try_deserialize(format: Literal['json'], dtype: DataTypeLike) -> Expression

Deserializes the expression (string) using the specified format and data type, inserting nulls on failures.

See Also

daft.functions.try_deserialize

Source code in daft/expressions/expressions.py
1470
1471
1472
1473
1474
1475
1476
1477
1478
def try_deserialize(self, format: Literal["json"], dtype: DataTypeLike) -> Expression:
    """Deserializes the expression (string) using the specified format and data type, inserting nulls on failures.

    Tip: See Also
        [`daft.functions.try_deserialize`](https://docs.daft.ai/en/stable/api/functions/try_deserialize/)
    """
    from daft.functions import try_deserialize

    return try_deserialize(self, format=format, dtype=dtype)

try_encode #

try_encode(charset: ENCODING_CHARSET) -> Expression

Encode or null if unsuccessful.

See Also

daft.functions.try_encode

Source code in daft/expressions/expressions.py
1400
1401
1402
1403
1404
1405
1406
1407
1408
def try_encode(self, charset: ENCODING_CHARSET) -> Expression:
    """Encode or null if unsuccessful.

    Tip: See Also
        [`daft.functions.try_encode`](https://docs.daft.ai/en/stable/api/functions/try_encode/)
    """
    from daft.functions import try_encode

    return try_encode(self, charset=charset)

udf #

udf(name: str, inner: UninitializedUdf, bound_args: BoundUDFArgs, expressions: list[Expression], return_dtype: DataType, init_args: InitArgsType, resource_request: ResourceRequest | None, batch_size: int | None, concurrency: int | None, use_process: bool | None, ray_options: dict[str, str] | None = None) -> Expression
Source code in daft/expressions/expressions.py
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@staticmethod
def udf(
    name: builtins.str,
    inner: UninitializedUdf,
    bound_args: BoundUDFArgs,
    expressions: builtins.list[Expression],
    return_dtype: DataType,
    init_args: InitArgsType,
    resource_request: ResourceRequest | None,
    batch_size: int | None,
    concurrency: int | None,
    use_process: bool | None,
    ray_options: dict[builtins.str, builtins.str] | None = None,
) -> Expression:
    return Expression._from_pyexpr(
        _udf(
            name,
            inner,
            bound_args,
            [e._expr for e in expressions],
            return_dtype._dtype,
            init_args,
            resource_request,
            batch_size,
            concurrency,
            use_process,
            ray_options,
        )
    )

unix_date #

unix_date() -> Expression

Retrieves the number of days since 1970-01-01 00:00:00 UTC.

See Also

daft.functions.unix_date

Source code in daft/expressions/expressions.py
1785
1786
1787
1788
1789
1790
1791
1792
1793
def unix_date(self) -> Expression:
    """Retrieves the number of days since 1970-01-01 00:00:00 UTC.

    Tip: See Also
        [`daft.functions.unix_date`](https://docs.daft.ai/en/stable/api/functions/unix_date/)
    """
    from daft.functions import unix_date

    return unix_date(self)

unnest #

unnest() -> Expression

Flatten the fields of a struct expression into columns in a DataFrame.

See Also

daft.functions.unnest

Source code in daft/expressions/expressions.py
206
207
208
209
210
211
212
213
214
def unnest(self) -> Expression:
    """Flatten the fields of a struct expression into columns in a DataFrame.

    Tip: See Also
        [`daft.functions.unnest`](https://docs.daft.ai/en/stable/api/functions/unnest/)
    """
    from daft.functions import unnest

    return unnest(self)

upload #

upload(location: str | Expression, max_connections: int = 32, on_error: Literal['raise', 'null'] = 'raise', io_config: IOConfig | None = None) -> Expression

Uploads a column of binary data to the provided location(s) (also supports S3, local etc).

See Also

daft.functions.upload

Source code in daft/expressions/expressions.py
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
def upload(
    self,
    location: builtins.str | Expression,
    max_connections: int = 32,
    on_error: Literal["raise", "null"] = "raise",
    io_config: IOConfig | None = None,
) -> Expression:
    """Uploads a column of binary data to the provided location(s) (also supports S3, local etc).

    Tip: See Also
        [`daft.functions.upload`](https://docs.daft.ai/en/stable/api/functions/upload/)
    """
    from daft.functions import upload

    return upload(self, location, max_connections, on_error, io_config)

upper #

upper() -> Expression

Convert UTF-8 string to all upper.

See Also

daft.functions.upper

Source code in daft/expressions/expressions.py
2031
2032
2033
2034
2035
2036
2037
2038
2039
def upper(self) -> Expression:
    """Convert UTF-8 string to all upper.

    Tip: See Also
        [`daft.functions.upper`](https://docs.daft.ai/en/stable/api/functions/upper/)
    """
    from daft.functions import upper

    return upper(self)

value_counts #

value_counts() -> Expression

Counts the occurrences of each distinct value in the list.

See Also

daft.functions.value_counts

Source code in daft/expressions/expressions.py
2377
2378
2379
2380
2381
2382
2383
2384
2385
def value_counts(self) -> Expression:
    """Counts the occurrences of each distinct value in the list.

    Tip: See Also
        [`daft.functions.value_counts`](https://docs.daft.ai/en/stable/api/functions/value_counts/)
    """
    from daft.functions import value_counts

    return value_counts(self)

var #

var(ddof: int = 1) -> Expression

Calculates the variance of the values in the expression.

Parameters:

Name Type Description Default
ddof int

Delta degrees of freedom. The divisor used in calculations is N - ddof, where N is the number of non-null elements. Defaults to 1 (sample variance).

1
See Also

daft.functions.var

Source code in daft/expressions/expressions.py
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
def var(self, ddof: int = 1) -> Expression:
    """Calculates the variance of the values in the expression.

    Args:
        ddof: Delta degrees of freedom. The divisor used in calculations
            is N - ddof, where N is the number of non-null elements.
            Defaults to 1 (sample variance).

    Tip: See Also
        [`daft.functions.var`](https://docs.daft.ai/en/stable/api/functions/var/)
    """
    from daft.functions import var

    return var(self, ddof)

video_frames #

video_frames(*, start_time: float = 0, end_time: float | None = None, width: int | None = None, height: int | None = None, is_key_frame: bool | None = None) -> Expression

Decodes video frames from a video file.

See Also

daft.functions.video_frames

Source code in daft/expressions/expressions.py
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
def video_frames(
    self,
    *,
    start_time: float = 0,
    end_time: float | None = None,
    width: int | None = None,
    height: int | None = None,
    is_key_frame: bool | None = None,
) -> Expression:
    """Decodes video frames from a video file.

    Tip: See Also
        [`daft.functions.video_frames`](https://docs.daft.ai/en/stable/api/functions/video_frames/)
    """
    from daft.functions import video_frames

    return video_frames(
        self,
        start_time=start_time,
        end_time=end_time,
        width=width,
        height=height,
        is_key_frame=is_key_frame,
    )

video_keyframes #

video_keyframes(*, start_time: float = 0, end_time: float | None = None) -> Expression

Gets keyframes for a video file.

See Also

daft.functions.video_keyframes

Source code in daft/expressions/expressions.py
2959
2960
2961
2962
2963
2964
2965
2966
2967
def video_keyframes(self, *, start_time: float = 0, end_time: float | None = None) -> Expression:
    """Gets keyframes for a video file.

    Tip: See Also
        [`daft.functions.video_keyframes`](https://docs.daft.ai/en/stable/api/functions/video_keyframes/)
    """
    from daft.functions import video_keyframes

    return video_keyframes(self, start_time=start_time, end_time=end_time)

video_metadata #

video_metadata() -> Expression

Gets metadata for a video file.

See Also

daft.functions.video_metadata

Source code in daft/expressions/expressions.py
2949
2950
2951
2952
2953
2954
2955
2956
2957
def video_metadata(self) -> Expression:
    """Gets metadata for a video file.

    Tip: See Also
        [`daft.functions.video_metadata`](https://docs.daft.ai/en/stable/api/functions/video_metadata/)
    """
    from daft.functions import video_metadata

    return video_metadata(self)

week_of_year #

week_of_year() -> Expression

Retrieves the week of the year for a datetime column.

See Also

daft.functions.week_of_year

Source code in daft/expressions/expressions.py
1861
1862
1863
1864
1865
1866
1867
1868
1869
def week_of_year(self) -> Expression:
    """Retrieves the week of the year for a datetime column.

    Tip: See Also
        [`daft.functions.week_of_year`](https://docs.daft.ai/en/stable/api/functions/week_of_year/)
    """
    from daft.functions import week_of_year

    return week_of_year(self)

year #

year() -> Expression

Retrieves the year for a datetime column.

See Also

daft.functions.year

Source code in daft/expressions/expressions.py
1821
1822
1823
1824
1825
1826
1827
1828
1829
def year(self) -> Expression:
    """Retrieves the year for a datetime column.

    Tip: See Also
        [`daft.functions.year`](https://docs.daft.ai/en/stable/api/functions/year/)
    """
    from daft.functions import year

    return year(self)

WhenExpr #

WhenExpr(cases: list[tuple[PyExpr, PyExpr]])

Helper class for building a SQL-style CASE WHEN expression.

See Also

daft.functions.when

This constructor should not be called directly. Please use daft.functions.when instead.

Methods:

Name Description
otherwise

Adds an ELSE ... clause to the CASE expression and returns a complete Expression.

when

Adds a WHEN ... THEN ... clause to the CASE expression.

Source code in daft/expressions/expressions.py
3017
3018
3019
3020
def __init__(self, cases: list[tuple[_PyExpr, _PyExpr]]):
    """This constructor should not be called directly. Please use `daft.functions.when` instead."""
    self._cases = cases
    self._expr = self._construct_pyexpr(self._cases, _lit(None))

otherwise #

otherwise(value: Expression | Any) -> Expression

Adds an ELSE ... clause to the CASE expression and returns a complete Expression.

See Also

daft.functions.when

Source code in daft/expressions/expressions.py
3047
3048
3049
3050
3051
3052
3053
3054
def otherwise(self, value: Expression | Any) -> Expression:
    """Adds an ELSE ... clause to the CASE expression and returns a complete Expression.

    Tip: See Also
        [`daft.functions.when`](https://docs.daft.ai/en/stable/api/functions/when/)
    """
    value = Expression._to_expression(value)
    return Expression._from_pyexpr(self._construct_pyexpr(self._cases, value._expr))

when #

when(condition: Expression | bool, then: Expression | Any) -> WhenExpr

Adds a WHEN ... THEN ... clause to the CASE expression.

Parameters:

Name Type Description Default
condition Expression | bool

The Boolean expression to evaluate

required
then Expression | Any

The value to return if the condition is true

required

Returns:

Type Description
WhenExpr

A new WhenExpr with the added condition and value.

See Also

daft.functions.when

Source code in daft/expressions/expressions.py
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
def when(self, condition: Expression | bool, then: Expression | Any) -> WhenExpr:
    """Adds a WHEN ... THEN ... clause to the CASE expression.

    Args:
        condition: The Boolean expression to evaluate
        then: The value to return if the condition is true

    Returns:
        A new WhenExpr with the added condition and value.

    Tip: See Also
        [`daft.functions.when`](https://docs.daft.ai/en/stable/api/functions/when/)
    """
    condition = Expression._to_expression(condition)
    then = Expression._to_expression(then)
    new_cases = self._cases + [(condition._expr, then._expr)]
    return WhenExpr(new_cases)

ExpressionVisitor #

ExpressionVisitor is an abstract base class for implementing the visitor pattern on expressions.

Examples:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
>>> from daft.expressions import ExpressionVisitor, col, lit
>>>
>>> class PrintVisitor(ExpressionVisitor[None]):
...     def visit_col(self, name: str) -> None:
...         print(f"Column: {name}")
...
...     def visit_lit(self, value: Any) -> None:
...         print(f"Literal: {value}")
...
...     def visit_alias(self, expr: Expression, alias: str) -> None:
...         print(f"Alias: {alias}")
...         self.visit(expr)
...
...     def visit_cast(self, expr: Expression, dtype: DataType) -> None:
...         print(f"Cast: {dtype}")
...         self.visit(expr)
...
...     def visit_try_cast(self, expr: Expression, dtype: DataType) -> None:
...         print(f"TryCast: {dtype}")
...         self.visit(expr)
...
...     def visit_function(self, name: str, args: list[Expression]) -> None:
...         print(f"Function: {name}")
...         for arg in args:
...             self.visit(arg)
>>> # Create an expression
>>> expr = col("x").cast("int64").alias("y")
>>>
>>> # Visit the expression
>>> visitor = PrintVisitor()
>>> visitor.visit(expr)
Alias: y
Cast: Int64
Column: x

Methods:

Name Description
visit

Visit an arbitrary expression, invoking this visitor.

visit_

Visit an arbitrary expression function, dispatching to an override if one exists.

visit_alias

Visit an alias expression.

visit_cast

Visit a cast expression.

visit_coalesce

Visit a coalesce expression.

visit_col

Visit a col expression.

visit_function

Visit a function call expression.

visit_lit

Visit a lit expression.

visit_try_cast

Visit a try_cast expression.

visit #

visit(expr: Expression) -> R

Visit an arbitrary expression, invoking this visitor.

Source code in daft/expressions/visitor.py
54
55
56
def visit(self, expr: Expression) -> R:
    """Visit an arbitrary expression, invoking this visitor."""
    return expr._expr.accept(self)

visit_ #

visit_(name: str, args: list[Expression]) -> R

Visit an arbitrary expression function, dispatching to an override if one exists.

Source code in daft/expressions/visitor.py
58
59
60
61
62
63
def visit_(self, name: str, args: list[Expression]) -> R:
    """Visit an arbitrary expression function, dispatching to an override if one exists."""
    if override := getattr(self, f"visit_{name}", None):
        return override(*args)
    else:
        return self.visit_function(name, args)

visit_alias #

visit_alias(expr: Expression, alias: str) -> R

Visit an alias expression.

Source code in daft/expressions/visitor.py
75
76
77
78
@abstractmethod
def visit_alias(self, expr: Expression, alias: str) -> R:
    """Visit an alias expression."""
    ...

visit_cast #

visit_cast(expr: Expression, dtype: DataType) -> R

Visit a cast expression.

Source code in daft/expressions/visitor.py
80
81
82
83
@abstractmethod
def visit_cast(self, expr: Expression, dtype: DataType) -> R:
    """Visit a cast expression."""
    ...

visit_coalesce #

visit_coalesce(args: list[Expression]) -> R

Visit a coalesce expression.

Source code in daft/expressions/visitor.py
 97
 98
 99
100
@abstractmethod
def visit_coalesce(self, args: list[Expression]) -> R:
    """Visit a coalesce expression."""
    ...

visit_col #

visit_col(name: str) -> R

Visit a col expression.

Source code in daft/expressions/visitor.py
65
66
67
68
@abstractmethod
def visit_col(self, name: str) -> R:
    """Visit a col expression."""
    ...

visit_function #

visit_function(name: str, args: list[Expression]) -> R

Visit a function call expression.

Source code in daft/expressions/visitor.py
92
93
94
95
@abstractmethod
def visit_function(self, name: str, args: list[Expression]) -> R:
    """Visit a function call expression."""
    ...

visit_lit #

visit_lit(value: Any) -> R

Visit a lit expression.

Source code in daft/expressions/visitor.py
70
71
72
73
@abstractmethod
def visit_lit(self, value: Any) -> R:
    """Visit a lit expression."""
    ...

visit_try_cast #

visit_try_cast(expr: Expression, dtype: DataType) -> R

Visit a try_cast expression.

Default implementation delegates to visit_cast for backwards compatibility.

Source code in daft/expressions/visitor.py
85
86
87
88
89
90
def visit_try_cast(self, expr: Expression, dtype: DataType) -> R:
    """Visit a try_cast expression.

    Default implementation delegates to visit_cast for backwards compatibility.
    """
    return self.visit_cast(expr, dtype)