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 | |
╭───────╮
│ 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 | |
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 | |
╭───────┬───────╮
│ 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 | |
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 | |
lit(1) + lit(2) Use SQL expression in a Daft DataFrame operation:
1 2 3 | |
╭───────┬───────┬───────╮
│ 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 | |
╭───────┬───────╮
│ 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 | |
Expression #
Expression()
Methods:
| Name | Description |
|---|---|
__abs__ | Absolute of a numeric expression. |
__add__ | Adds two numeric expressions or concatenates two string expressions ( |
__and__ | Takes the logical AND of two boolean expressions, or bitwise AND of two integer expressions ( |
__bool__ | |
__eq__ | Compares if an expression is equal to another ( |
__floordiv__ | Floor divides two numeric expressions ( |
__ge__ | Compares if an expression is greater than or equal to another ( |
__getitem__ | Syntactic sugar for |
__gt__ | Compares if an expression is greater than another ( |
__hash__ | |
__invert__ | Inverts a boolean expression ( |
__le__ | Compares if an expression is less than or equal to another ( |
__lshift__ | Shifts the bits of an integer expression to the left ( |
__lt__ | Compares if an expression is less than another ( |
__mod__ | Takes the mod of two numeric expressions ( |
__mul__ | Multiplies two numeric expressions ( |
__ne__ | Compares if an expression is not equal to another ( |
__or__ | Takes the logical OR of two boolean or integer expressions, or bitwise OR of two integer expressions ( |
__radd__ | |
__rand__ | Takes the logical reverse AND of two boolean expressions ( |
__reduce__ | |
__repr__ | |
__rfloordiv__ | Reverse floor divides two numeric expressions ( |
__rmod__ | Takes the mod of two numeric expressions ( |
__rmul__ | |
__ror__ | Takes the logical reverse OR of two boolean expressions ( |
__rshift__ | Shifts the bits of an integer expression to the right ( |
__rsub__ | |
__rtruediv__ | |
__sub__ | Subtracts two numeric expressions ( |
__truediv__ | True divides two numeric expressions ( |
__xor__ | Takes the logical XOR of two boolean or integer expressions, or bitwise XOR of two integer expressions ( |
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- |
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 |
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 |
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 |
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 ( |
shift_right | Shifts the bits of an integer expression to the right ( |
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 | |
__abs__ #
__abs__() -> Expression
Absolute of a numeric expression.
Source code in daft/expressions/expressions.py
222 223 224 | |
__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 | |
__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 | |
__bool__ #
__bool__() -> bool
Source code in daft/expressions/expressions.py
216 217 218 219 220 | |
__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 | |
__floordiv__ #
__floordiv__(other: Expression) -> Expression
Floor divides two numeric expressions (e1 / e2).
Source code in daft/expressions/expressions.py
375 376 377 378 | |
__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 | |
__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 | |
╭───────┬───────╮
│ x ┆ first │
│ --- ┆ --- │
│ Int64 ┆ Int64 │
╞═══════╪═══════╡
│ 1 ┆ 10 │
├╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
│ 3 ┆ 30 │
╰───────┴───────╯
(Showing first 2 of 2 rows) Getting a slice:
1 2 3 | |
╭─────────────╮
│ x │
│ --- │
│ List[Int64] │
╞═════════════╡
│ [2] │
├╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ [5, 6] │
├╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ [] │
╰─────────────╯
(Showing first 3 of 3 rows) See Also
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 | |
__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 | |
__hash__ #
__hash__() -> int
Source code in daft/expressions/expressions.py
1562 1563 | |
__invert__ #
__invert__() -> Expression
Inverts a boolean expression (~e).
Source code in daft/expressions/expressions.py
370 371 372 373 | |
__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 | |
__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 | |
__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 | |
__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 | |
__mul__ #
__mul__(other: object) -> Expression
Multiplies two numeric expressions (e1 * e2).
Source code in daft/expressions/expressions.py
254 255 256 257 | |
__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 | |
__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 | |
__radd__ #
__radd__(other: object) -> Expression
Source code in daft/expressions/expressions.py
241 242 243 | |
__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 | |
__reduce__ #
__reduce__() -> tuple[Callable[[PyExpr], Expression], tuple[PyExpr]]
Source code in daft/expressions/expressions.py
1565 1566 | |
__repr__ #
__repr__() -> str
Source code in daft/expressions/expressions.py
1553 1554 | |
__rfloordiv__ #
__rfloordiv__(other: object) -> Expression
Reverse floor divides two numeric expressions (e2 / e1).
Source code in daft/expressions/expressions.py
380 381 382 383 | |
__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 | |
__rmul__ #
__rmul__(other: object) -> Expression
Source code in daft/expressions/expressions.py
259 260 261 | |
__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 | |
__rshift__ #
__rshift__(other: Expression) -> Expression
Shifts the bits of an integer expression to the right (e1 >> e2).
.. NOTE::
1 2 | |
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 | |
__rsub__ #
__rsub__(other: object) -> Expression
Source code in daft/expressions/expressions.py
250 251 252 | |
__rtruediv__ #
__rtruediv__(other: object) -> Expression
Source code in daft/expressions/expressions.py
268 269 270 | |
__sub__ #
__sub__(other: object) -> Expression
Subtracts two numeric expressions (e1 - e2).
Source code in daft/expressions/expressions.py
245 246 247 248 | |
__truediv__ #
__truediv__(other: object) -> Expression
True divides two numeric expressions (e1 / e2).
Source code in daft/expressions/expressions.py
263 264 265 266 | |
__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 | |
abs #
abs() -> Expression
Absolute of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
226 227 228 229 230 231 232 233 234 | |
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 | |
╭───────╮
│ 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 | |
any_value #
any_value(ignore_nulls: bool = False) -> Expression
Returns any value in the expression.
See Also
Source code in daft/expressions/expressions.py
1156 1157 1158 1159 1160 1161 1162 1163 1164 | |
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 | |
╭────────┬───────╮
│ 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 | |
approx_count_distinct #
approx_count_distinct() -> Expression
Calculates the approximate number of non-NULL distinct values in the expression.
See Also
Source code in daft/expressions/expressions.py
1030 1031 1032 1033 1034 1035 1036 1037 1038 | |
approx_percentiles #
approx_percentiles(percentiles: float | list[float]) -> Expression
Calculates the approximate percentile(s) for a column of numeric values.
See Also
Source code in daft/expressions/expressions.py
1040 1041 1042 1043 1044 1045 1046 1047 1048 | |
arccos #
arccos() -> Expression
The elementwise arc cosine of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
770 771 772 773 774 775 776 777 778 | |
arccosh #
arccosh() -> Expression
The elementwise inverse hyperbolic cosine of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
810 811 812 813 814 815 816 817 818 | |
arcsin #
arcsin() -> Expression
The elementwise arc sine of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
760 761 762 763 764 765 766 767 768 | |
arcsinh #
arcsinh() -> Expression
The elementwise inverse hyperbolic sine of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
820 821 822 823 824 825 826 827 828 | |
arctan #
arctan() -> Expression
The elementwise arc tangent of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
780 781 782 783 784 785 786 787 788 | |
arctan2 #
arctan2(other: Expression) -> Expression
Calculates the four quadrant arctangent of coordinates (y, x), in radians.
See Also
Source code in daft/expressions/expressions.py
790 791 792 793 794 795 796 797 798 | |
arctanh #
arctanh() -> Expression
The elementwise inverse hyperbolic tangent of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
800 801 802 803 804 805 806 807 808 | |
as_binary #
as_binary() -> Expression
Source code in daft/expressions/expressions.py
539 | |
as_bool #
as_bool() -> Expression
Source code in daft/expressions/expressions.py
537 | |
as_date #
as_date() -> Expression
Source code in daft/expressions/expressions.py
547 | |
as_decimal128 #
as_decimal128(precision: int, scale: int) -> Expression
Source code in daft/expressions/expressions.py
545 | |
as_duration #
as_duration(timeunit: TimeUnit | str) -> Expression
Source code in daft/expressions/expressions.py
553 | |
as_embedding #
as_embedding(dtype: DataType, size: int) -> Expression
Source code in daft/expressions/expressions.py
567 | |
as_extension #
as_extension(name: str, storage_dtype: DataType, metadata: str | None = ...) -> Expression
Source code in daft/expressions/expressions.py
565 | |
as_file #
as_file(media_type: MediaType = ...) -> Expression
Source code in daft/expressions/expressions.py
584 | |
as_fixed_size_binary #
as_fixed_size_binary(size: int) -> Expression
Source code in daft/expressions/expressions.py
541 | |
as_fixed_size_list #
as_fixed_size_list(dtype: DataType, size: int) -> Expression
Source code in daft/expressions/expressions.py
559 | |
as_float32 #
as_float32() -> Expression
Source code in daft/expressions/expressions.py
531 | |
as_float64 #
as_float64() -> Expression
Source code in daft/expressions/expressions.py
533 | |
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 | |
as_int16 #
as_int16() -> Expression
Source code in daft/expressions/expressions.py
517 | |
as_int32 #
as_int32() -> Expression
Source code in daft/expressions/expressions.py
519 | |
as_int64 #
as_int64() -> Expression
Source code in daft/expressions/expressions.py
521 | |
as_int8 #
as_int8() -> Expression
Source code in daft/expressions/expressions.py
515 | |
as_interval #
as_interval() -> Expression
Source code in daft/expressions/expressions.py
555 | |
as_list #
as_list(dtype: DataType) -> Expression
Source code in daft/expressions/expressions.py
557 | |
as_map #
as_map(key_type: DataType, value_type: DataType) -> Expression
Source code in daft/expressions/expressions.py
561 | |
as_null #
as_null() -> Expression
Source code in daft/expressions/expressions.py
543 | |
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 | |
as_python #
as_python() -> Expression
Source code in daft/expressions/expressions.py
582 | |
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 | |
as_string #
as_string() -> Expression
Source code in daft/expressions/expressions.py
535 | |
as_struct #
as_struct(fields: dict[str, DataType]) -> Expression
Source code in daft/expressions/expressions.py
563 | |
as_tensor #
as_tensor(dtype: DataType, shape: tuple[int, ...] | None = ...) -> Expression
Source code in daft/expressions/expressions.py
573 | |
as_time #
as_time(timeunit: TimeUnit | str) -> Expression
Source code in daft/expressions/expressions.py
549 | |
as_timestamp #
as_timestamp(timeunit: TimeUnit | str, timezone: str | None = ...) -> Expression
Source code in daft/expressions/expressions.py
551 | |
as_uint16 #
as_uint16() -> Expression
Source code in daft/expressions/expressions.py
525 | |
as_uint32 #
as_uint32() -> Expression
Source code in daft/expressions/expressions.py
527 | |
as_uint64 #
as_uint64() -> Expression
Source code in daft/expressions/expressions.py
529 | |
as_uint8 #
as_uint8() -> Expression
Source code in daft/expressions/expressions.py
523 | |
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 | |
between #
between(lower: int | float, upper: int | float) -> Expression
Checks if values in the Expression are between lower and upper, inclusive.
See Also
Source code in daft/expressions/expressions.py
1314 1315 1316 1317 1318 1319 1320 1321 1322 | |
bitwise_and #
bitwise_and(other: Expression) -> Expression
Bitwise AND of two integer expressions.
See Also
Source code in daft/expressions/expressions.py
940 941 942 943 944 945 946 947 948 | |
bitwise_or #
bitwise_or(other: Expression) -> Expression
Bitwise OR of two integer expressions.
See Also
Source code in daft/expressions/expressions.py
950 951 952 953 954 955 956 957 958 | |
bitwise_xor #
bitwise_xor(other: Expression) -> Expression
Bitwise XOR of two integer expressions.
See Also
Source code in daft/expressions/expressions.py
960 961 962 963 964 965 966 967 968 | |
bool_and #
bool_and() -> Expression
Calculates the boolean AND of all values in a list.
See Also
Source code in daft/expressions/expressions.py
1136 1137 1138 1139 1140 1141 1142 1143 1144 | |
bool_or #
bool_or() -> Expression
Calculates the boolean OR of all values in a list.
See Also
Source code in daft/expressions/expressions.py
1146 1147 1148 1149 1150 1151 1152 1153 1154 | |
capitalize #
capitalize() -> Expression
Capitalize a UTF-8 string.
See Also
Source code in daft/expressions/expressions.py
2081 2082 2083 2084 2085 2086 2087 2088 2089 | |
cast #
cast(dtype: DataTypeLike) -> Expression
Casts an expression to the given datatype if possible.
See Also
Source code in daft/expressions/expressions.py
490 491 492 493 494 495 496 497 498 | |
cbrt #
cbrt() -> Expression
The cube root of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
660 661 662 663 664 665 666 667 668 | |
ceil #
ceil() -> Expression
The ceiling of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
586 587 588 589 590 591 592 593 594 | |
chunk #
chunk(size: int) -> Expression
Splits each list into chunks of the given size.
See Also
Source code in daft/expressions/expressions.py
2387 2388 2389 2390 2391 2392 2393 2394 2395 | |
clip #
clip(min: Expression | None = None, max: Expression | None = None) -> Expression
Clips an expression to the given minimum and maximum values.
See Also
Source code in daft/expressions/expressions.py
606 607 608 609 610 611 612 613 614 615 616 617 618 | |
coalesce #
coalesce(*others: Expression) -> Expression
Returns the first non-null value among this expression and the provided expressions.
See Also
Source code in daft/expressions/expressions.py
2586 2587 2588 2589 2590 2591 2592 2593 2594 | |
column_name #
column_name() -> str | None
Source code in daft/expressions/expressions.py
156 157 | |
compress #
compress(codec: COMPRESSION_CODEC) -> Expression
Compress binary or string values using the specified codec.
See Also
Source code in daft/expressions/expressions.py
1420 1421 1422 1423 1424 1425 1426 1427 1428 | |
concat #
concat(other: Expression | str | bytes) -> Expression
Concatenate two string expressions.
See Also
Source code in daft/expressions/expressions.py
1668 1669 1670 1671 1672 1673 1674 1675 1676 | |
contains #
contains(substr: str | Expression) -> Expression
Checks whether each string contains the given pattern in a string column.
See Also
Source code in daft/expressions/expressions.py
1991 1992 1993 1994 1995 1996 1997 1998 1999 | |
convert_image #
convert_image(mode: str | ImageMode) -> Expression
Convert an image expression to the specified mode.
See Also
Source code in daft/expressions/expressions.py
2674 2675 2676 2677 2678 2679 2680 2681 2682 | |
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
Source code in daft/expressions/expressions.py
1971 1972 1973 1974 1975 1976 1977 1978 1979 | |
cos #
cos() -> Expression
The elementwise cosine of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
680 681 682 683 684 685 686 687 688 | |
cosh #
cosh() -> Expression
The elementwise hyperbolic cosine of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
740 741 742 743 744 745 746 747 748 | |
cosine_distance #
cosine_distance(other: Expression) -> Expression
Compute the cosine distance between two embeddings.
See Also
Source code in daft/expressions/expressions.py
1598 1599 1600 1601 1602 1603 1604 1605 1606 | |
cosine_similarity #
cosine_similarity(other: Expression) -> Expression
Compute the cosine similarity between two embeddings.
See Also
Source code in daft/expressions/expressions.py
1628 1629 1630 1631 1632 1633 1634 1635 1636 | |
cot #
cot() -> Expression
The elementwise cotangent of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
720 721 722 723 724 725 726 727 728 | |
count #
count(mode: Literal['all', 'valid', 'null'] | CountMode = Valid) -> Expression
Counts the number of values in the expression.
See Also
Source code in daft/expressions/expressions.py
990 991 992 993 994 995 996 997 998 | |
count_distinct #
count_distinct() -> Expression
Counts the number of distinct values in the expression.
See Also
Source code in daft/expressions/expressions.py
1000 1001 1002 1003 1004 1005 1006 1007 1008 | |
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
Source code in daft/expressions/expressions.py
2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 | |
crop #
crop(bbox: tuple[int, int, int, int] | Expression) -> Expression
Crops images with the provided bounding box.
See Also
Source code in daft/expressions/expressions.py
2407 2408 2409 2410 2411 2412 2413 2414 2415 | |
csc #
csc() -> Expression
The elementwise cosecant of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
700 701 702 703 704 705 706 707 708 | |
date #
date() -> Expression
Retrieves the date for a datetime column.
Source code in daft/expressions/expressions.py
1709 1710 1711 1712 1713 | |
date_trunc #
date_trunc(interval: str, relative_to: Expression | None = None) -> Expression
Truncates the datetime column to the specified interval.
See Also
Source code in daft/expressions/expressions.py
2596 2597 2598 2599 2600 2601 2602 2603 2604 | |
day #
day() -> Expression
Retrieves the day for a datetime column.
See Also
Source code in daft/expressions/expressions.py
1715 1716 1717 1718 1719 1720 1721 1722 1723 | |
day_of_month #
day_of_month() -> Expression
Retrieves the day of the month for a datetime column.
See Also
Source code in daft/expressions/expressions.py
1841 1842 1843 1844 1845 1846 1847 1848 1849 | |
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
Source code in daft/expressions/expressions.py
1831 1832 1833 1834 1835 1836 1837 1838 1839 | |
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
Source code in daft/expressions/expressions.py
1851 1852 1853 1854 1855 1856 1857 1858 1859 | |
decode #
decode(charset: ENCODING_CHARSET) -> Expression
Decodes binary values using the specified character set.
See Also
Source code in daft/expressions/expressions.py
1390 1391 1392 1393 1394 1395 1396 1397 1398 | |
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
Source code in daft/expressions/expressions.py
2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 | |
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 | |
decompress #
decompress(codec: COMPRESSION_CODEC) -> Expression
Decompress binary values using the specified codec.
See Also
Source code in daft/expressions/expressions.py
1430 1431 1432 1433 1434 1435 1436 1437 1438 | |
degrees #
degrees() -> Expression
The elementwise degrees of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
840 841 842 843 844 845 846 847 848 | |
deserialize #
deserialize(format: Literal['json'], dtype: DataTypeLike) -> Expression
Deserializes the expression (string) using the specified format and data type.
See Also
Source code in daft/expressions/expressions.py
1460 1461 1462 1463 1464 1465 1466 1467 1468 | |
dot_product #
dot_product(other: Expression) -> Expression
Compute the dot product between two embeddings.
See Also
Source code in daft/expressions/expressions.py
1618 1619 1620 1621 1622 1623 1624 1625 1626 | |
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
Source code in daft/expressions/expressions.py
1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 | |
encode #
encode(charset: ENCODING_CHARSET) -> Expression
Encode binary or string values using the specified character set.
See Also
Source code in daft/expressions/expressions.py
1380 1381 1382 1383 1384 1385 1386 1387 1388 | |
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
Source code in daft/expressions/expressions.py
2562 2563 2564 2565 2566 2567 2568 2569 2570 | |
endswith #
endswith(suffix: str | Expression) -> Expression
Checks whether each string ends with the given pattern in a string column.
See Also
Source code in daft/expressions/expressions.py
2241 2242 2243 2244 2245 2246 2247 2248 2249 | |
eq_null_safe #
eq_null_safe(other: Expression | Any) -> Expression
Performs a null-safe equality comparison between two expressions.
See Also
Source code in daft/expressions/expressions.py
322 323 324 325 326 327 328 329 330 | |
euclidean_distance #
euclidean_distance(other: Expression) -> Expression
Compute the Euclidean distance between two embeddings.
See Also
Source code in daft/expressions/expressions.py
1608 1609 1610 1611 1612 1613 1614 1615 1616 | |
exp #
exp() -> Expression
The e^self of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
920 921 922 923 924 925 926 927 928 | |
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
Source code in daft/expressions/expressions.py
1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 | |
expm1 #
expm1() -> Expression
The e^self - 1 of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
930 931 932 933 934 935 936 937 938 | |
file_path #
file_path() -> Expression
Gets the path (URL) of a file as a string.
See Also
Source code in daft/expressions/expressions.py
2929 2930 2931 2932 2933 2934 2935 2936 2937 | |
file_size #
file_size() -> Expression
Gets the size of a file in bytes.
See Also
Source code in daft/expressions/expressions.py
2939 2940 2941 2942 2943 2944 2945 2946 2947 | |
fill_nan #
fill_nan(fill_value: Expression) -> Expression
Fills NaN values in the Expression with the provided fill_value.
See Also
Source code in daft/expressions/expressions.py
2844 2845 2846 2847 2848 2849 2850 2851 2852 | |
fill_null #
fill_null(fill_value: Expression | Any) -> Expression
Fills null values in the Expression with the provided fill_value.
See Also
Source code in daft/expressions/expressions.py
1291 1292 1293 1294 1295 1296 1297 1298 1299 | |
find #
find(substr: str | Expression) -> Expression
Returns the index of the first occurrence of the substring in each string.
See Also
Source code in daft/expressions/expressions.py
2664 2665 2666 2667 2668 2669 2670 2671 2672 | |
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 | |
floor #
floor() -> Expression
The floor of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
596 597 598 599 600 601 602 603 604 | |
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
Source code in daft/expressions/expressions.py
2704 2705 2706 2707 2708 2709 2710 2711 2712 | |
hamming_distance #
hamming_distance(other: Expression) -> Expression
Compute the bitwise Hamming distance between two hash fingerprints.
See Also
Source code in daft/expressions/expressions.py
1370 1371 1372 1373 1374 1375 1376 1377 1378 | |
hamming_distance_str #
hamming_distance_str(other: Expression) -> Expression
Compute the character-level Hamming distance between two strings.
See Also
Source code in daft/expressions/expressions.py
2367 2368 2369 2370 2371 2372 2373 2374 2375 | |
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 | |
hour #
hour() -> Expression
Retrieves the hour for a datetime column.
See Also
Source code in daft/expressions/expressions.py
1725 1726 1727 1728 1729 1730 1731 1732 1733 | |
ilike #
ilike(pattern: str | Expression) -> Expression
Checks whether each string matches the given SQL ILIKE pattern, case insensitive.
See Also
Source code in daft/expressions/expressions.py
2221 2222 2223 2224 2225 2226 2227 2228 2229 | |
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
Source code in daft/expressions/expressions.py
2854 2855 2856 2857 2858 2859 2860 2861 2862 | |
image_channel #
image_channel() -> Expression
Gets the number of channels in an image.
See Also
Source code in daft/expressions/expressions.py
2884 2885 2886 2887 2888 2889 2890 2891 2892 | |
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 | |
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
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 | |
image_height #
image_height() -> Expression
Gets the height of an image in pixels.
See Also
Source code in daft/expressions/expressions.py
2874 2875 2876 2877 2878 2879 2880 2881 2882 | |
image_mode #
image_mode() -> Expression
Gets the mode of an image as a string.
See Also
Source code in daft/expressions/expressions.py
2894 2895 2896 2897 2898 2899 2900 2901 2902 | |
image_to_tensor #
image_to_tensor() -> Expression
Convert an image expression to a tensor, inferring dtype and shape.
See Also
Source code in daft/expressions/expressions.py
2684 2685 2686 2687 2688 2689 2690 2691 2692 | |
image_width #
image_width() -> Expression
Gets the width of an image in pixels.
See Also
Source code in daft/expressions/expressions.py
2864 2865 2866 2867 2868 2869 2870 2871 2872 | |
is_column #
is_column() -> bool
Source code in daft/expressions/expressions.py
150 151 | |
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
Source code in daft/expressions/expressions.py
1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 | |
is_inf #
is_inf() -> Expression
Checks if values in the Expression are Infinity.
See Also
Source code in daft/expressions/expressions.py
2824 2825 2826 2827 2828 2829 2830 2831 2832 | |
is_literal #
is_literal() -> bool
Source code in daft/expressions/expressions.py
153 154 | |
is_nan #
is_nan() -> Expression
Checks if values are NaN (a special float value indicating not-a-number).
See Also
Source code in daft/expressions/expressions.py
2814 2815 2816 2817 2818 2819 2820 2821 2822 | |
is_null #
is_null() -> Expression
Checks if values in the Expression are Null (a special value indicating missing data).
See Also
Source code in daft/expressions/expressions.py
1271 1272 1273 1274 1275 1276 1277 1278 1279 | |
jaccard_similarity #
jaccard_similarity(other: Expression) -> Expression
Compute the Jaccard similarity between two embeddings.
See Also
Source code in daft/expressions/expressions.py
1648 1649 1650 1651 1652 1653 1654 1655 1656 | |
jq #
jq(filter: str) -> Expression
Applies a jq filter to the expression (string), returning the results as a string.
See Also
Source code in daft/expressions/expressions.py
1490 1491 1492 1493 1494 1495 1496 1497 1498 | |
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 | |
left #
left(nchars: int | Expression) -> Expression
Gets the n (from nchars) left-most characters of each string.
See Also
Source code in daft/expressions/expressions.py
2161 2162 2163 2164 2165 2166 2167 2168 2169 | |
length #
length() -> Expression
Retrieves the length of the given expression.
See Also
Source code in daft/expressions/expressions.py
1658 1659 1660 1661 1662 1663 1664 1665 1666 | |
length_bytes #
length_bytes() -> Expression
Retrieves the length for a UTF-8 string column in bytes.
See Also
Source code in daft/expressions/expressions.py
2357 2358 2359 2360 2361 2362 2363 2364 2365 | |
like #
like(pattern: str | Expression) -> Expression
Checks whether each string matches the given SQL LIKE pattern, case sensitive.
See Also
Source code in daft/expressions/expressions.py
2211 2212 2213 2214 2215 2216 2217 2218 2219 | |
list_agg #
list_agg() -> Expression
Aggregates the values in the expression into a list.
See Also
Source code in daft/expressions/expressions.py
1176 1177 1178 1179 1180 1181 1182 1183 1184 | |
list_agg_distinct #
list_agg_distinct() -> Expression
Aggregates the values in the expression into a list of distinct values (ignoring nulls).
See Also
Source code in daft/expressions/expressions.py
1186 1187 1188 1189 1190 1191 1192 1193 1194 | |
list_append #
list_append(other: Expression) -> Expression
Appends a value to each list in the column.
See Also
Source code in daft/expressions/expressions.py
2694 2695 2696 2697 2698 2699 2700 2701 2702 | |
list_bool_and #
list_bool_and() -> Expression
Calculates the boolean AND of all values in a list.
See Also
Source code in daft/expressions/expressions.py
2490 2491 2492 2493 2494 2495 2496 2497 2498 | |
list_bool_or #
list_bool_or() -> Expression
Calculates the boolean OR of all values in a list.
See Also
Source code in daft/expressions/expressions.py
2500 2501 2502 2503 2504 2505 2506 2507 2508 | |
list_contains #
list_contains(item: Expression) -> Expression
Checks if each list contains the specified item.
See Also
Source code in daft/expressions/expressions.py
2532 2533 2534 2535 2536 2537 2538 2539 2540 | |
list_count #
list_count(mode: Literal['all', 'valid', 'null'] | CountMode = Valid) -> Expression
Counts the number of elements in each list.
See Also
Source code in daft/expressions/expressions.py
2440 2441 2442 2443 2444 2445 2446 2447 2448 | |
list_distinct #
list_distinct() -> Expression
Returns a list of unique elements in each list, preserving order of first occurrence and ignoring nulls.
See Also
Source code in daft/expressions/expressions.py
2522 2523 2524 2525 2526 2527 2528 2529 2530 | |
list_filter #
list_filter(predicate: Expression) -> Expression
Filters elements in the list using a boolean predicate over daft.element().
See Also
Source code in daft/expressions/expressions.py
2552 2553 2554 2555 2556 2557 2558 2559 2560 | |
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
Source code in daft/expressions/expressions.py
2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 | |
list_join #
list_join(delimiter: str | Expression) -> Expression
Joins every element of a list using the specified string delimiter.
See Also
Source code in daft/expressions/expressions.py
2417 2418 2419 2420 2421 2422 2423 2424 2425 | |
list_map #
list_map(mapper: Expression) -> Expression
Evaluates an expression on all elements in the list.
See Also
Source code in daft/expressions/expressions.py
2542 2543 2544 2545 2546 2547 2548 2549 2550 | |
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
Source code in daft/expressions/expressions.py
2480 2481 2482 2483 2484 2485 2486 2487 2488 | |
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
Source code in daft/expressions/expressions.py
2460 2461 2462 2463 2464 2465 2466 2467 2468 | |
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
Source code in daft/expressions/expressions.py
2470 2471 2472 2473 2474 2475 2476 2477 2478 | |
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
Source code in daft/expressions/expressions.py
2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 | |
list_sum #
list_sum() -> Expression
Sums each list. Empty lists and lists with all nulls yield null.
See Also
Source code in daft/expressions/expressions.py
2450 2451 2452 2453 2454 2455 2456 2457 2458 | |
ln #
ln() -> Expression
The elementwise natural log of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
880 881 882 883 884 885 886 887 888 | |
log #
log(base: int | float = e) -> Expression
The elementwise log with given base, of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
870 871 872 873 874 875 876 877 878 | |
log10 #
log10() -> Expression
The elementwise log base 10 of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
860 861 862 863 864 865 866 867 868 | |
log1p #
log1p() -> Expression
The ln(self + 1) of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
890 891 892 893 894 895 896 897 898 | |
log2 #
log2() -> Expression
The elementwise log base 2 of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
850 851 852 853 854 855 856 857 858 | |
lower #
lower() -> Expression
Convert UTF-8 string to all lowercase.
See Also
Source code in daft/expressions/expressions.py
2021 2022 2023 2024 2025 2026 2027 2028 2029 | |
lpad #
lpad(length: int | Expression, pad: str | Expression) -> Expression
Left-pads each string by truncating or padding with the character.
See Also
Source code in daft/expressions/expressions.py
2191 2192 2193 2194 2195 2196 2197 2198 2199 | |
lstrip #
lstrip() -> Expression
Strip whitespace from the left side of a UTF-8 string.
See Also
Source code in daft/expressions/expressions.py
2041 2042 2043 2044 2045 2046 2047 2048 2049 | |
map_get #
map_get(key: Expression) -> Expression
Retrieves the value for a key in a map column.
See Also
Source code in daft/expressions/expressions.py
2714 2715 2716 2717 2718 2719 2720 2721 2722 | |
map_keys #
map_keys() -> Expression
Returns a list of all keys in the map.
See Also
Source code in daft/expressions/expressions.py
2724 2725 2726 2727 2728 2729 2730 2731 2732 | |
max #
max() -> Expression
Calculates the maximum value in the expression.
See Also
Source code in daft/expressions/expressions.py
1126 1127 1128 1129 1130 1131 1132 1133 1134 | |
mean #
mean() -> Expression
Calculates the mean of the values in the expression.
See Also
Source code in daft/expressions/expressions.py
1050 1051 1052 1053 1054 1055 1056 1057 1058 | |
median #
median() -> Expression
Calculates the median of the values in the expression.
See Also
Source code in daft/expressions/expressions.py
1076 1077 1078 1079 1080 1081 1082 1083 1084 | |
microsecond #
microsecond() -> Expression
Retrieves the microsecond for a datetime column.
See Also
Source code in daft/expressions/expressions.py
1765 1766 1767 1768 1769 1770 1771 1772 1773 | |
millisecond #
millisecond() -> Expression
Retrieves the millisecond for a datetime column.
See Also
Source code in daft/expressions/expressions.py
1755 1756 1757 1758 1759 1760 1761 1762 1763 | |
min #
min() -> Expression
Calculates the minimum value in the expression.
See Also
Source code in daft/expressions/expressions.py
1116 1117 1118 1119 1120 1121 1122 1123 1124 | |
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
Source code in daft/expressions/expressions.py
1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 | |
minute #
minute() -> Expression
Retrieves the minute for a datetime column.
See Also
Source code in daft/expressions/expressions.py
1735 1736 1737 1738 1739 1740 1741 1742 1743 | |
month #
month() -> Expression
Retrieves the month for a datetime column.
See Also
Source code in daft/expressions/expressions.py
1801 1802 1803 1804 1805 1806 1807 1808 1809 | |
name #
name() -> str
Source code in daft/expressions/expressions.py
1500 1501 | |
nanosecond #
nanosecond() -> Expression
Retrieves the nanosecond for a datetime column.
See Also
Source code in daft/expressions/expressions.py
1775 1776 1777 1778 1779 1780 1781 1782 1783 | |
negate #
negate() -> Expression
The negative of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
630 631 632 633 634 635 636 637 638 | |
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
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 | |
not_nan #
not_nan() -> Expression
Checks if values are not NaN (a special float value indicating not-a-number).
See Also
Source code in daft/expressions/expressions.py
2834 2835 2836 2837 2838 2839 2840 2841 2842 | |
not_null #
not_null() -> Expression
Checks if values in the Expression are not Null (a special value indicating missing data).
See Also
Source code in daft/expressions/expressions.py
1281 1282 1283 1284 1285 1286 1287 1288 1289 | |
parse_url #
parse_url() -> Expression
Parse string URLs and extract URL components.
See Also
Source code in daft/expressions/expressions.py
1574 1575 1576 1577 1578 1579 1580 1581 1582 | |
partition_days #
partition_days() -> Expression
Partitioning Transform that returns the number of days since epoch (1970-01-01).
See Also
Source code in daft/expressions/expressions.py
2754 2755 2756 2757 2758 2759 2760 2761 2762 | |
partition_hours #
partition_hours() -> Expression
Partitioning Transform that returns the number of hours since epoch (1970-01-01).
See Also
Source code in daft/expressions/expressions.py
2764 2765 2766 2767 2768 2769 2770 2771 2772 | |
partition_iceberg_bucket #
partition_iceberg_bucket(n: int) -> Expression
Partitioning Transform that returns the Hash Bucket following the Iceberg Specification of murmur3_32_x86.
Source code in daft/expressions/expressions.py
2794 2795 2796 2797 2798 2799 2800 2801 2802 | |
partition_iceberg_truncate #
partition_iceberg_truncate(w: int) -> Expression
Partitioning Transform that truncates the input to a standard width w following the Iceberg Specification.
Source code in daft/expressions/expressions.py
2804 2805 2806 2807 2808 2809 2810 2811 2812 | |
partition_months #
partition_months() -> Expression
Partitioning Transform that returns the number of months since epoch (1970-01-01).
See Also
Source code in daft/expressions/expressions.py
2774 2775 2776 2777 2778 2779 2780 2781 2782 | |
partition_years #
partition_years() -> Expression
Partitioning Transform that returns the number of years since epoch (1970-01-01).
See Also
Source code in daft/expressions/expressions.py
2784 2785 2786 2787 2788 2789 2790 2791 2792 | |
pearson_correlation #
pearson_correlation(other: Expression) -> Expression
Compute the Pearson correlation between two embeddings.
See Also
Source code in daft/expressions/expressions.py
1638 1639 1640 1641 1642 1643 1644 1645 1646 | |
percentile #
percentile(percentage: float) -> Expression
Calculates the exact percentile for a column of numeric values.
See Also
Source code in daft/expressions/expressions.py
1066 1067 1068 1069 1070 1071 1072 1073 1074 | |
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 | |
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 | |
product #
product() -> Expression
Calculates the product of the values in the expression.
See Also
Source code in daft/expressions/expressions.py
1020 1021 1022 1023 1024 1025 1026 1027 1028 | |
quarter #
quarter() -> Expression
Retrieves the quarter for a datetime column.
See Also
Source code in daft/expressions/expressions.py
1811 1812 1813 1814 1815 1816 1817 1818 1819 | |
radians #
radians() -> Expression
The elementwise radians of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
830 831 832 833 834 835 836 837 838 | |
regexp #
regexp(pattern: str | Expression) -> Expression
Check whether each string matches the given regular expression pattern in a string column.
See Also
Source code in daft/expressions/expressions.py
2606 2607 2608 2609 2610 2611 2612 2613 2614 | |
regexp_count #
regexp_count(pattern: str | Expression) -> Expression
Counts the number of times a regex pattern appears in a string.
See Also
Source code in daft/expressions/expressions.py
2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 | |
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
Source code in daft/expressions/expressions.py
2616 2617 2618 2619 2620 2621 2622 2623 2624 | |
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
Source code in daft/expressions/expressions.py
2626 2627 2628 2629 2630 2631 2632 2633 2634 | |
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
Source code in daft/expressions/expressions.py
2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 | |
regexp_split #
regexp_split(pattern: str | Expression) -> Expression
Splits each string on the given regex pattern, into a list of strings.
See Also
Source code in daft/expressions/expressions.py
2011 2012 2013 2014 2015 2016 2017 2018 2019 | |
repeat #
repeat(n: int | Expression) -> Expression
Repeats each string n times.
See Also
Source code in daft/expressions/expressions.py
2201 2202 2203 2204 2205 2206 2207 2208 2209 | |
replace #
replace(search: str | Expression, replacement: str | Expression) -> Expression
Replaces all occurrences of a substring in a string with a replacement string.
See Also
Source code in daft/expressions/expressions.py
2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 | |
replace_time_zone #
replace_time_zone(timezone: str | None = None) -> Expression
Replaces the timezone of a timestamp while preserving the local time.
See Also
Source code in daft/expressions/expressions.py
1981 1982 1983 1984 1985 1986 1987 1988 1989 | |
resize #
resize(w: int, h: int) -> Expression
Resize image into the provided width and height.
See Also
Source code in daft/expressions/expressions.py
2397 2398 2399 2400 2401 2402 2403 2404 2405 | |
reverse #
reverse() -> Expression
Reverse a UTF-8 string.
See Also
Source code in daft/expressions/expressions.py
2071 2072 2073 2074 2075 2076 2077 2078 2079 | |
right #
right(nchars: int | Expression) -> Expression
Gets the n (from nchars) right-most characters of each string.
See Also
Source code in daft/expressions/expressions.py
2171 2172 2173 2174 2175 2176 2177 2178 2179 | |
round #
round(decimals: Expression | int = 0) -> Expression
The round of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
640 641 642 643 644 645 646 647 648 | |
rpad #
rpad(length: int | Expression, pad: str | Expression) -> Expression
Right-pads each string by truncating or padding with the character.
See Also
Source code in daft/expressions/expressions.py
2181 2182 2183 2184 2185 2186 2187 2188 2189 | |
rstrip #
rstrip() -> Expression
Strip whitespace from the right side of a UTF-8 string.
See Also
Source code in daft/expressions/expressions.py
2051 2052 2053 2054 2055 2056 2057 2058 2059 | |
sec #
sec() -> Expression
The elementwise secant of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
710 711 712 713 714 715 716 717 718 | |
second #
second() -> Expression
Retrieves the second for a datetime column.
See Also
Source code in daft/expressions/expressions.py
1745 1746 1747 1748 1749 1750 1751 1752 1753 | |
serialize #
serialize(format: Literal['json']) -> Expression
Serializes the expression as a string using the specified format.
See Also
Source code in daft/expressions/expressions.py
1480 1481 1482 1483 1484 1485 1486 1487 1488 | |
shift_left #
shift_left(other: Expression) -> Expression
Shifts the bits of an integer expression to the left (expr << other).
See Also
Source code in daft/expressions/expressions.py
970 971 972 973 974 975 976 977 978 | |
shift_right #
shift_right(other: Expression) -> Expression
Shifts the bits of an integer expression to the right (expr >> other).
See Also
Source code in daft/expressions/expressions.py
980 981 982 983 984 985 986 987 988 | |
sign #
sign() -> Expression
The sign of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
620 621 622 623 624 625 626 627 628 | |
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
Source code in daft/expressions/expressions.py
1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 | |
sin #
sin() -> Expression
The elementwise sine of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
670 671 672 673 674 675 676 677 678 | |
sinh #
sinh() -> Expression
The elementwise hyperbolic sine of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
730 731 732 733 734 735 736 737 738 | |
skew #
skew() -> Expression
Calculates the skewness of the values from the expression.
See Also
Source code in daft/expressions/expressions.py
1166 1167 1168 1169 1170 1171 1172 1173 1174 | |
slice #
slice(start: int | Expression, end: int | Expression | None = None) -> Expression
Get a subset of each list or binary value.
See Also
Source code in daft/expressions/expressions.py
2734 2735 2736 2737 2738 2739 2740 2741 2742 | |
split #
split(split_on: str | Expression) -> Expression
Splits each string on the given string, into a list of strings.
See Also
Source code in daft/expressions/expressions.py
2001 2002 2003 2004 2005 2006 2007 2008 2009 | |
sqrt #
sqrt() -> Expression
The square root of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
650 651 652 653 654 655 656 657 658 | |
startswith #
startswith(prefix: str | Expression) -> Expression
Checks whether each string starts with the given pattern in a string column.
See Also
Source code in daft/expressions/expressions.py
2251 2252 2253 2254 2255 2256 2257 2258 2259 | |
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
Source code in daft/expressions/expressions.py
1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 | |
strftime #
strftime(format: str | None = None) -> Expression
Converts a datetime/date column to a string column.
See Also
Source code in daft/expressions/expressions.py
1871 1872 1873 1874 1875 1876 1877 1878 1879 | |
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
Source code in daft/expressions/expressions.py
1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 | |
strip #
strip() -> Expression
Strip whitespace from both sides of a UTF-8 string.
See Also
Source code in daft/expressions/expressions.py
2061 2062 2063 2064 2065 2066 2067 2068 2069 | |
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
Source code in daft/expressions/expressions.py
2231 2232 2233 2234 2235 2236 2237 2238 2239 | |
sum #
sum() -> Expression
Calculates the sum of the values in the expression.
See Also
Source code in daft/expressions/expressions.py
1010 1011 1012 1013 1014 1015 1016 1017 1018 | |
tan #
tan() -> Expression
The elementwise tangent of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
690 691 692 693 694 695 696 697 698 | |
tanh #
tanh() -> Expression
The elementwise hyperbolic tangent of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
750 751 752 753 754 755 756 757 758 | |
time #
time() -> Expression
Retrieves the time for a datetime column.
Source code in daft/expressions/expressions.py
1795 1796 1797 1798 1799 | |
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 | |
to_camel_case #
to_camel_case() -> Expression
Convert a string to lower camel case.
See Also
Source code in daft/expressions/expressions.py
2091 2092 2093 2094 2095 2096 2097 2098 2099 | |
to_date #
to_date(format: str) -> Expression
Converts a string to a date using the specified format.
See Also
Source code in daft/expressions/expressions.py
1951 1952 1953 1954 1955 1956 1957 1958 1959 | |
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
Source code in daft/expressions/expressions.py
1961 1962 1963 1964 1965 1966 1967 1968 1969 | |
to_kebab_case #
to_kebab_case() -> Expression
Convert a string to kebab case.
See Also
Source code in daft/expressions/expressions.py
2131 2132 2133 2134 2135 2136 2137 2138 2139 | |
to_snake_case #
to_snake_case() -> Expression
Convert a string to snake case.
See Also
Source code in daft/expressions/expressions.py
2111 2112 2113 2114 2115 2116 2117 2118 2119 | |
to_title_case #
to_title_case() -> Expression
Convert a string to title case.
See Also
Source code in daft/expressions/expressions.py
2151 2152 2153 2154 2155 2156 2157 2158 2159 | |
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
Source code in daft/expressions/expressions.py
2744 2745 2746 2747 2748 2749 2750 2751 2752 | |
to_upper_camel_case #
to_upper_camel_case() -> Expression
Convert a string to upper camel case.
See Also
Source code in daft/expressions/expressions.py
2101 2102 2103 2104 2105 2106 2107 2108 2109 | |
to_upper_kebab_case #
to_upper_kebab_case() -> Expression
Convert a string to upper kebab case.
See Also
Source code in daft/expressions/expressions.py
2141 2142 2143 2144 2145 2146 2147 2148 2149 | |
to_upper_snake_case #
to_upper_snake_case() -> Expression
Convert a string to upper snake case.
See Also
Source code in daft/expressions/expressions.py
2121 2122 2123 2124 2125 2126 2127 2128 2129 | |
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
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 | |
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
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 | |
total_days #
total_days() -> Expression
Calculates the total number of days for a duration column.
See Also
Source code in daft/expressions/expressions.py
1941 1942 1943 1944 1945 1946 1947 1948 1949 | |
total_hours #
total_hours() -> Expression
Calculates the total number of hours for a duration column.
See Also
Source code in daft/expressions/expressions.py
1931 1932 1933 1934 1935 1936 1937 1938 1939 | |
total_microseconds #
total_microseconds() -> Expression
Calculates the total number of microseconds for a duration column.
See Also
Source code in daft/expressions/expressions.py
1901 1902 1903 1904 1905 1906 1907 1908 1909 | |
total_milliseconds #
total_milliseconds() -> Expression
Calculates the total number of milliseconds for a duration column.
See Also
Source code in daft/expressions/expressions.py
1891 1892 1893 1894 1895 1896 1897 1898 1899 | |
total_minutes #
total_minutes() -> Expression
Calculates the total number of minutes for a duration column.
See Also
Source code in daft/expressions/expressions.py
1921 1922 1923 1924 1925 1926 1927 1928 1929 | |
total_nanoseconds #
total_nanoseconds() -> Expression
Calculates the total number of nanoseconds for a duration column.
See Also
Source code in daft/expressions/expressions.py
1911 1912 1913 1914 1915 1916 1917 1918 1919 | |
total_seconds #
total_seconds() -> Expression
Calculates the total number of seconds for a duration column.
See Also
Source code in daft/expressions/expressions.py
1881 1882 1883 1884 1885 1886 1887 1888 1889 | |
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
Source code in daft/expressions/expressions.py
500 501 502 503 504 505 506 507 508 509 510 511 | |
try_compress #
try_compress(codec: COMPRESSION_CODEC) -> Expression
Compress or null if unsuccessful.
See Also
Source code in daft/expressions/expressions.py
1440 1441 1442 1443 1444 1445 1446 1447 1448 | |
try_decode #
try_decode(charset: ENCODING_CHARSET) -> Expression
Decode or null if unsuccessful.
See Also
Source code in daft/expressions/expressions.py
1410 1411 1412 1413 1414 1415 1416 1417 1418 | |
try_decompress #
try_decompress(codec: COMPRESSION_CODEC) -> Expression
Decompress or null if unsuccessful.
See Also
Source code in daft/expressions/expressions.py
1450 1451 1452 1453 1454 1455 1456 1457 1458 | |
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
Source code in daft/expressions/expressions.py
1470 1471 1472 1473 1474 1475 1476 1477 1478 | |
try_encode #
try_encode(charset: ENCODING_CHARSET) -> Expression
Encode or null if unsuccessful.
See Also
Source code in daft/expressions/expressions.py
1400 1401 1402 1403 1404 1405 1406 1407 1408 | |
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 | |
unix_date #
unix_date() -> Expression
Retrieves the number of days since 1970-01-01 00:00:00 UTC.
See Also
Source code in daft/expressions/expressions.py
1785 1786 1787 1788 1789 1790 1791 1792 1793 | |
unnest #
unnest() -> Expression
Flatten the fields of a struct expression into columns in a DataFrame.
See Also
Source code in daft/expressions/expressions.py
206 207 208 209 210 211 212 213 214 | |
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
Source code in daft/expressions/expressions.py
1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 | |
upper #
upper() -> Expression
Convert UTF-8 string to all upper.
See Also
Source code in daft/expressions/expressions.py
2031 2032 2033 2034 2035 2036 2037 2038 2039 | |
value_counts #
value_counts() -> Expression
Counts the occurrences of each distinct value in the list.
See Also
Source code in daft/expressions/expressions.py
2377 2378 2379 2380 2381 2382 2383 2384 2385 | |
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
Source code in daft/expressions/expressions.py
1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 | |
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
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 | |
video_keyframes #
video_keyframes(*, start_time: float = 0, end_time: float | None = None) -> Expression
Gets keyframes for a video file.
See Also
Source code in daft/expressions/expressions.py
2959 2960 2961 2962 2963 2964 2965 2966 2967 | |
video_metadata #
video_metadata() -> Expression
Gets metadata for a video file.
See Also
Source code in daft/expressions/expressions.py
2949 2950 2951 2952 2953 2954 2955 2956 2957 | |
week_of_year #
week_of_year() -> Expression
Retrieves the week of the year for a datetime column.
See Also
Source code in daft/expressions/expressions.py
1861 1862 1863 1864 1865 1866 1867 1868 1869 | |
year #
year() -> Expression
Retrieves the year for a datetime column.
See Also
Source code in daft/expressions/expressions.py
1821 1822 1823 1824 1825 1826 1827 1828 1829 | |
WhenExpr #
WhenExpr(cases: list[tuple[PyExpr, PyExpr]])
Helper class for building a SQL-style CASE WHEN expression.
See Also
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 | |
otherwise #
otherwise(value: Expression | Any) -> Expression
Adds an ELSE ... clause to the CASE expression and returns a complete Expression.
See Also
Source code in daft/expressions/expressions.py
3047 3048 3049 3050 3051 3052 3053 3054 | |
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
Source code in daft/expressions/expressions.py
3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 | |
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 | |
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 | |
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 | |
visit_alias #
visit_alias(expr: Expression, alias: str) -> R
Visit an alias expression.
Source code in daft/expressions/visitor.py
75 76 77 78 | |
visit_cast #
visit_cast(expr: Expression, dtype: DataType) -> R
Visit a cast expression.
Source code in daft/expressions/visitor.py
80 81 82 83 | |
visit_coalesce #
visit_coalesce(args: list[Expression]) -> R
Visit a coalesce expression.
Source code in daft/expressions/visitor.py
97 98 99 100 | |
visit_col #
visit_col(name: str) -> R
Visit a col expression.
Source code in daft/expressions/visitor.py
65 66 67 68 | |
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 | |
visit_lit #
visit_lit(value: Any) -> R
Visit a lit expression.
Source code in daft/expressions/visitor.py
70 71 72 73 | |
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 | |