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. |
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. |
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_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
1529 1530 | |
__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
1532 1533 | |
__repr__ #
__repr__() -> str
Source code in daft/expressions/expressions.py
1520 1521 | |
__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
1143 1144 1145 1146 1147 1148 1149 1150 1151 | |
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
1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 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 | |
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
1017 1018 1019 1020 1021 1022 1023 1024 1025 | |
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
1027 1028 1029 1030 1031 1032 1033 1034 1035 | |
arccos #
arccos() -> Expression
The elementwise arc cosine of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
757 758 759 760 761 762 763 764 765 | |
arccosh #
arccosh() -> Expression
The elementwise inverse hyperbolic cosine of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
797 798 799 800 801 802 803 804 805 | |
arcsin #
arcsin() -> Expression
The elementwise arc sine of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
747 748 749 750 751 752 753 754 755 | |
arcsinh #
arcsinh() -> Expression
The elementwise inverse hyperbolic sine of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
807 808 809 810 811 812 813 814 815 | |
arctan #
arctan() -> Expression
The elementwise arc tangent of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
767 768 769 770 771 772 773 774 775 | |
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
777 778 779 780 781 782 783 784 785 | |
arctanh #
arctanh() -> Expression
The elementwise inverse hyperbolic tangent of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
787 788 789 790 791 792 793 794 795 | |
as_binary #
as_binary() -> Expression
Source code in daft/expressions/expressions.py
526 | |
as_bool #
as_bool() -> Expression
Source code in daft/expressions/expressions.py
524 | |
as_date #
as_date() -> Expression
Source code in daft/expressions/expressions.py
534 | |
as_decimal128 #
as_decimal128(precision: int, scale: int) -> Expression
Source code in daft/expressions/expressions.py
532 | |
as_duration #
as_duration(timeunit: TimeUnit | str) -> Expression
Source code in daft/expressions/expressions.py
540 | |
as_embedding #
as_embedding(dtype: DataType, size: int) -> Expression
Source code in daft/expressions/expressions.py
554 | |
as_extension #
as_extension(name: str, storage_dtype: DataType, metadata: str | None = ...) -> Expression
Source code in daft/expressions/expressions.py
552 | |
as_file #
as_file(media_type: MediaType = ...) -> Expression
Source code in daft/expressions/expressions.py
571 | |
as_fixed_size_binary #
as_fixed_size_binary(size: int) -> Expression
Source code in daft/expressions/expressions.py
528 | |
as_fixed_size_list #
as_fixed_size_list(dtype: DataType, size: int) -> Expression
Source code in daft/expressions/expressions.py
546 | |
as_float32 #
as_float32() -> Expression
Source code in daft/expressions/expressions.py
518 | |
as_float64 #
as_float64() -> Expression
Source code in daft/expressions/expressions.py
520 | |
as_image #
as_image(mode: str | ImageMode | None = ..., height: int | None = ..., width: int | None = ...) -> Expression
Source code in daft/expressions/expressions.py
556 557 558 | |
as_int16 #
as_int16() -> Expression
Source code in daft/expressions/expressions.py
504 | |
as_int32 #
as_int32() -> Expression
Source code in daft/expressions/expressions.py
506 | |
as_int64 #
as_int64() -> Expression
Source code in daft/expressions/expressions.py
508 | |
as_int8 #
as_int8() -> Expression
Source code in daft/expressions/expressions.py
502 | |
as_interval #
as_interval() -> Expression
Source code in daft/expressions/expressions.py
542 | |
as_list #
as_list(dtype: DataType) -> Expression
Source code in daft/expressions/expressions.py
544 | |
as_map #
as_map(key_type: DataType, value_type: DataType) -> Expression
Source code in daft/expressions/expressions.py
548 | |
as_null #
as_null() -> Expression
Source code in daft/expressions/expressions.py
530 | |
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
569 | |
as_sparse_tensor #
as_sparse_tensor(dtype: DataType, shape: tuple[int, ...] | None = ..., use_offset_indices: bool = ...) -> Expression
Source code in daft/expressions/expressions.py
562 563 564 565 566 567 | |
as_string #
as_string() -> Expression
Source code in daft/expressions/expressions.py
522 | |
as_struct #
as_struct(fields: dict[str, DataType]) -> Expression
Source code in daft/expressions/expressions.py
550 | |
as_tensor #
as_tensor(dtype: DataType, shape: tuple[int, ...] | None = ...) -> Expression
Source code in daft/expressions/expressions.py
560 | |
as_time #
as_time(timeunit: TimeUnit | str) -> Expression
Source code in daft/expressions/expressions.py
536 | |
as_timestamp #
as_timestamp(timeunit: TimeUnit | str, timezone: str | None = ...) -> Expression
Source code in daft/expressions/expressions.py
538 | |
as_uint16 #
as_uint16() -> Expression
Source code in daft/expressions/expressions.py
512 | |
as_uint32 #
as_uint32() -> Expression
Source code in daft/expressions/expressions.py
514 | |
as_uint64 #
as_uint64() -> Expression
Source code in daft/expressions/expressions.py
516 | |
as_uint8 #
as_uint8() -> Expression
Source code in daft/expressions/expressions.py
510 | |
avg #
avg() -> Expression
Alias for Expression.mean(). Check Expression.mean for more details.
Source code in daft/expressions/expressions.py
1047 1048 1049 1050 1051 | |
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
1301 1302 1303 1304 1305 1306 1307 1308 1309 | |
bitwise_and #
bitwise_and(other: Expression) -> Expression
Bitwise AND of two integer expressions.
See Also
Source code in daft/expressions/expressions.py
927 928 929 930 931 932 933 934 935 | |
bitwise_or #
bitwise_or(other: Expression) -> Expression
Bitwise OR of two integer expressions.
See Also
Source code in daft/expressions/expressions.py
937 938 939 940 941 942 943 944 945 | |
bitwise_xor #
bitwise_xor(other: Expression) -> Expression
Bitwise XOR of two integer expressions.
See Also
Source code in daft/expressions/expressions.py
947 948 949 950 951 952 953 954 955 | |
bool_and #
bool_and() -> Expression
Calculates the boolean AND of all values in a list.
See Also
Source code in daft/expressions/expressions.py
1123 1124 1125 1126 1127 1128 1129 1130 1131 | |
bool_or #
bool_or() -> Expression
Calculates the boolean OR of all values in a list.
See Also
Source code in daft/expressions/expressions.py
1133 1134 1135 1136 1137 1138 1139 1140 1141 | |
capitalize #
capitalize() -> Expression
Capitalize a UTF-8 string.
See Also
Source code in daft/expressions/expressions.py
2048 2049 2050 2051 2052 2053 2054 2055 2056 | |
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
647 648 649 650 651 652 653 654 655 | |
ceil #
ceil() -> Expression
The ceiling of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
573 574 575 576 577 578 579 580 581 | |
chunk #
chunk(size: int) -> Expression
Splits each list into chunks of the given size.
See Also
Source code in daft/expressions/expressions.py
2354 2355 2356 2357 2358 2359 2360 2361 2362 | |
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
593 594 595 596 597 598 599 600 601 602 603 604 605 | |
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
2553 2554 2555 2556 2557 2558 2559 2560 2561 | |
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
1407 1408 1409 1410 1411 1412 1413 1414 1415 | |
concat #
concat(other: Expression | str | bytes) -> Expression
Concatenate two string expressions.
See Also
Source code in daft/expressions/expressions.py
1635 1636 1637 1638 1639 1640 1641 1642 1643 | |
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
1958 1959 1960 1961 1962 1963 1964 1965 1966 | |
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
2641 2642 2643 2644 2645 2646 2647 2648 2649 | |
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
1938 1939 1940 1941 1942 1943 1944 1945 1946 | |
cos #
cos() -> Expression
The elementwise cosine of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
667 668 669 670 671 672 673 674 675 | |
cosh #
cosh() -> Expression
The elementwise hyperbolic cosine of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
727 728 729 730 731 732 733 734 735 | |
cosine_distance #
cosine_distance(other: Expression) -> Expression
Compute the cosine distance between two embeddings.
See Also
Source code in daft/expressions/expressions.py
1565 1566 1567 1568 1569 1570 1571 1572 1573 | |
cosine_similarity #
cosine_similarity(other: Expression) -> Expression
Compute the cosine similarity between two embeddings.
See Also
Source code in daft/expressions/expressions.py
1595 1596 1597 1598 1599 1600 1601 1602 1603 | |
cot #
cot() -> Expression
The elementwise cotangent of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
707 708 709 710 711 712 713 714 715 | |
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
977 978 979 980 981 982 983 984 985 | |
count_distinct #
count_distinct() -> Expression
Counts the number of distinct values in the expression.
See Also
Source code in daft/expressions/expressions.py
987 988 989 990 991 992 993 994 995 | |
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
2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 | |
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
2374 2375 2376 2377 2378 2379 2380 2381 2382 | |
csc #
csc() -> Expression
The elementwise cosecant of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
687 688 689 690 691 692 693 694 695 | |
date #
date() -> Expression
Retrieves the date for a datetime column.
Source code in daft/expressions/expressions.py
1676 1677 1678 1679 1680 | |
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
2563 2564 2565 2566 2567 2568 2569 2570 2571 | |
day #
day() -> Expression
Retrieves the day for a datetime column.
See Also
Source code in daft/expressions/expressions.py
1682 1683 1684 1685 1686 1687 1688 1689 1690 | |
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
1808 1809 1810 1811 1812 1813 1814 1815 1816 | |
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
1798 1799 1800 1801 1802 1803 1804 1805 1806 | |
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
1818 1819 1820 1821 1822 1823 1824 1825 1826 | |
decode #
decode(charset: ENCODING_CHARSET) -> Expression
Decodes binary values using the specified character set.
See Also
Source code in daft/expressions/expressions.py
1377 1378 1379 1380 1381 1382 1383 1384 1385 | |
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
2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 | |
decode_image_file #
decode_image_file() -> Expression
Decodes an image file into an Image column.
Source code in daft/expressions/expressions.py
2970 2971 2972 2973 2974 | |
decompress #
decompress(codec: COMPRESSION_CODEC) -> Expression
Decompress binary values using the specified codec.
See Also
Source code in daft/expressions/expressions.py
1417 1418 1419 1420 1421 1422 1423 1424 1425 | |
degrees #
degrees() -> Expression
The elementwise degrees of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
827 828 829 830 831 832 833 834 835 | |
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
1447 1448 1449 1450 1451 1452 1453 1454 1455 | |
dot_product #
dot_product(other: Expression) -> Expression
Compute the dot product between two embeddings.
See Also
Source code in daft/expressions/expressions.py
1585 1586 1587 1588 1589 1590 1591 1592 1593 | |
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
1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 | |
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
1367 1368 1369 1370 1371 1372 1373 1374 1375 | |
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
2529 2530 2531 2532 2533 2534 2535 2536 2537 | |
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
2208 2209 2210 2211 2212 2213 2214 2215 2216 | |
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
1575 1576 1577 1578 1579 1580 1581 1582 1583 | |
exp #
exp() -> Expression
The e^self of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
907 908 909 910 911 912 913 914 915 | |
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
1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 | |
expm1 #
expm1() -> Expression
The e^self - 1 of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
917 918 919 920 921 922 923 924 925 | |
file_path #
file_path() -> Expression
Gets the path (URL) of a file as a string.
See Also
Source code in daft/expressions/expressions.py
2896 2897 2898 2899 2900 2901 2902 2903 2904 | |
file_size #
file_size() -> Expression
Gets the size of a file in bytes.
See Also
Source code in daft/expressions/expressions.py
2906 2907 2908 2909 2910 2911 2912 2913 2914 | |
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
2811 2812 2813 2814 2815 2816 2817 2818 2819 | |
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
1278 1279 1280 1281 1282 1283 1284 1285 1286 | |
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
2631 2632 2633 2634 2635 2636 2637 2638 2639 | |
floor #
floor() -> Expression
The floor of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
583 584 585 586 587 588 589 590 591 | |
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
2671 2672 2673 2674 2675 2676 2677 2678 2679 | |
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
1357 1358 1359 1360 1361 1362 1363 1364 1365 | |
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
2334 2335 2336 2337 2338 2339 2340 2341 2342 | |
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
1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 | |
hour #
hour() -> Expression
Retrieves the hour for a datetime column.
See Also
Source code in daft/expressions/expressions.py
1692 1693 1694 1695 1696 1697 1698 1699 1700 | |
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
2188 2189 2190 2191 2192 2193 2194 2195 2196 | |
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
2821 2822 2823 2824 2825 2826 2827 2828 2829 | |
image_channel #
image_channel() -> Expression
Gets the number of channels in an image.
See Also
Source code in daft/expressions/expressions.py
2851 2852 2853 2854 2855 2856 2857 2858 2859 | |
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
2961 2962 2963 2964 2965 2966 2967 2968 | |
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
2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 | |
image_height #
image_height() -> Expression
Gets the height of an image in pixels.
See Also
Source code in daft/expressions/expressions.py
2841 2842 2843 2844 2845 2846 2847 2848 2849 | |
image_mode #
image_mode() -> Expression
Gets the mode of an image as a string.
See Also
Source code in daft/expressions/expressions.py
2861 2862 2863 2864 2865 2866 2867 2868 2869 | |
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
2651 2652 2653 2654 2655 2656 2657 2658 2659 | |
image_width #
image_width() -> Expression
Gets the width of an image in pixels.
See Also
Source code in daft/expressions/expressions.py
2831 2832 2833 2834 2835 2836 2837 2838 2839 | |
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
1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 | |
is_inf #
is_inf() -> Expression
Checks if values in the Expression are Infinity.
See Also
Source code in daft/expressions/expressions.py
2791 2792 2793 2794 2795 2796 2797 2798 2799 | |
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
2781 2782 2783 2784 2785 2786 2787 2788 2789 | |
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
1258 1259 1260 1261 1262 1263 1264 1265 1266 | |
jaccard_similarity #
jaccard_similarity(other: Expression) -> Expression
Compute the Jaccard similarity between two embeddings.
See Also
Source code in daft/expressions/expressions.py
1615 1616 1617 1618 1619 1620 1621 1622 1623 | |
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
1477 1478 1479 1480 1481 1482 1483 1484 1485 | |
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
2128 2129 2130 2131 2132 2133 2134 2135 2136 | |
length #
length() -> Expression
Retrieves the length of the given expression.
See Also
Source code in daft/expressions/expressions.py
1625 1626 1627 1628 1629 1630 1631 1632 1633 | |
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
2324 2325 2326 2327 2328 2329 2330 2331 2332 | |
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
2178 2179 2180 2181 2182 2183 2184 2185 2186 | |
list_agg #
list_agg() -> Expression
Aggregates the values in the expression into a list.
See Also
Source code in daft/expressions/expressions.py
1163 1164 1165 1166 1167 1168 1169 1170 1171 | |
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
1173 1174 1175 1176 1177 1178 1179 1180 1181 | |
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
2661 2662 2663 2664 2665 2666 2667 2668 2669 | |
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
2457 2458 2459 2460 2461 2462 2463 2464 2465 | |
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
2467 2468 2469 2470 2471 2472 2473 2474 2475 | |
list_contains #
list_contains(item: Expression) -> Expression
Checks if each list contains the specified item.
See Also
Source code in daft/expressions/expressions.py
2499 2500 2501 2502 2503 2504 2505 2506 2507 | |
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
2407 2408 2409 2410 2411 2412 2413 2414 2415 | |
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
2489 2490 2491 2492 2493 2494 2495 2496 2497 | |
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
2519 2520 2521 2522 2523 2524 2525 2526 2527 | |
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
2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 | |
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
2384 2385 2386 2387 2388 2389 2390 2391 2392 | |
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
2509 2510 2511 2512 2513 2514 2515 2516 2517 | |
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
2447 2448 2449 2450 2451 2452 2453 2454 2455 | |
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
2427 2428 2429 2430 2431 2432 2433 2434 2435 | |
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
2437 2438 2439 2440 2441 2442 2443 2444 2445 | |
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
2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 | |
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
2417 2418 2419 2420 2421 2422 2423 2424 2425 | |
ln #
ln() -> Expression
The elementwise natural log of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
867 868 869 870 871 872 873 874 875 | |
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
857 858 859 860 861 862 863 864 865 | |
log10 #
log10() -> Expression
The elementwise log base 10 of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
847 848 849 850 851 852 853 854 855 | |
log1p #
log1p() -> Expression
The ln(self + 1) of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
877 878 879 880 881 882 883 884 885 | |
log2 #
log2() -> Expression
The elementwise log base 2 of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
837 838 839 840 841 842 843 844 845 | |
lower #
lower() -> Expression
Convert UTF-8 string to all lowercase.
See Also
Source code in daft/expressions/expressions.py
1988 1989 1990 1991 1992 1993 1994 1995 1996 | |
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
2158 2159 2160 2161 2162 2163 2164 2165 2166 | |
lstrip #
lstrip() -> Expression
Strip whitespace from the left side of a UTF-8 string.
See Also
Source code in daft/expressions/expressions.py
2008 2009 2010 2011 2012 2013 2014 2015 2016 | |
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
2681 2682 2683 2684 2685 2686 2687 2688 2689 | |
map_keys #
map_keys() -> Expression
Returns a list of all keys in the map.
See Also
Source code in daft/expressions/expressions.py
2691 2692 2693 2694 2695 2696 2697 2698 2699 | |
max #
max() -> Expression
Calculates the maximum value in the expression.
See Also
Source code in daft/expressions/expressions.py
1113 1114 1115 1116 1117 1118 1119 1120 1121 | |
mean #
mean() -> Expression
Calculates the mean of the values in the expression.
See Also
Source code in daft/expressions/expressions.py
1037 1038 1039 1040 1041 1042 1043 1044 1045 | |
median #
median() -> Expression
Calculates the median of the values in the expression.
See Also
Source code in daft/expressions/expressions.py
1063 1064 1065 1066 1067 1068 1069 1070 1071 | |
microsecond #
microsecond() -> Expression
Retrieves the microsecond for a datetime column.
See Also
Source code in daft/expressions/expressions.py
1732 1733 1734 1735 1736 1737 1738 1739 1740 | |
millisecond #
millisecond() -> Expression
Retrieves the millisecond for a datetime column.
See Also
Source code in daft/expressions/expressions.py
1722 1723 1724 1725 1726 1727 1728 1729 1730 | |
min #
min() -> Expression
Calculates the minimum value in the expression.
See Also
Source code in daft/expressions/expressions.py
1103 1104 1105 1106 1107 1108 1109 1110 1111 | |
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
1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 | |
minute #
minute() -> Expression
Retrieves the minute for a datetime column.
See Also
Source code in daft/expressions/expressions.py
1702 1703 1704 1705 1706 1707 1708 1709 1710 | |
month #
month() -> Expression
Retrieves the month for a datetime column.
See Also
Source code in daft/expressions/expressions.py
1768 1769 1770 1771 1772 1773 1774 1775 1776 | |
name #
name() -> str
Source code in daft/expressions/expressions.py
1487 1488 | |
nanosecond #
nanosecond() -> Expression
Retrieves the nanosecond for a datetime column.
See Also
Source code in daft/expressions/expressions.py
1742 1743 1744 1745 1746 1747 1748 1749 1750 | |
negate #
negate() -> Expression
The negative of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
617 618 619 620 621 622 623 624 625 | |
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
2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 | |
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
2801 2802 2803 2804 2805 2806 2807 2808 2809 | |
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
1268 1269 1270 1271 1272 1273 1274 1275 1276 | |
parse_url #
parse_url() -> Expression
Parse string URLs and extract URL components.
See Also
Source code in daft/expressions/expressions.py
1541 1542 1543 1544 1545 1546 1547 1548 1549 | |
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
2721 2722 2723 2724 2725 2726 2727 2728 2729 | |
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
2731 2732 2733 2734 2735 2736 2737 2738 2739 | |
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
2761 2762 2763 2764 2765 2766 2767 2768 2769 | |
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
2771 2772 2773 2774 2775 2776 2777 2778 2779 | |
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
2741 2742 2743 2744 2745 2746 2747 2748 2749 | |
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
2751 2752 2753 2754 2755 2756 2757 2758 2759 | |
pearson_correlation #
pearson_correlation(other: Expression) -> Expression
Compute the Pearson correlation between two embeddings.
See Also
Source code in daft/expressions/expressions.py
1605 1606 1607 1608 1609 1610 1611 1612 1613 | |
percentile #
percentile(percentage: float) -> Expression
Calculates the exact percentile for a column of numeric values.
See Also
Source code in daft/expressions/expressions.py
1053 1054 1055 1056 1057 1058 1059 1060 1061 | |
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
887 888 889 890 891 892 893 894 895 | |
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
897 898 899 900 901 902 903 904 905 | |
product #
product() -> Expression
Calculates the product of the values in the expression.
See Also
Source code in daft/expressions/expressions.py
1007 1008 1009 1010 1011 1012 1013 1014 1015 | |
quarter #
quarter() -> Expression
Retrieves the quarter for a datetime column.
See Also
Source code in daft/expressions/expressions.py
1778 1779 1780 1781 1782 1783 1784 1785 1786 | |
radians #
radians() -> Expression
The elementwise radians of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
817 818 819 820 821 822 823 824 825 | |
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
2573 2574 2575 2576 2577 2578 2579 2580 2581 | |
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
2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 | |
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
2583 2584 2585 2586 2587 2588 2589 2590 2591 | |
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
2593 2594 2595 2596 2597 2598 2599 2600 2601 | |
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
2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 | |
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
1978 1979 1980 1981 1982 1983 1984 1985 1986 | |
repeat #
repeat(n: int | Expression) -> Expression
Repeats each string n times.
See Also
Source code in daft/expressions/expressions.py
2168 2169 2170 2171 2172 2173 2174 2175 2176 | |
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
2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 | |
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
1948 1949 1950 1951 1952 1953 1954 1955 1956 | |
resize #
resize(w: int, h: int) -> Expression
Resize image into the provided width and height.
See Also
Source code in daft/expressions/expressions.py
2364 2365 2366 2367 2368 2369 2370 2371 2372 | |
reverse #
reverse() -> Expression
Reverse a UTF-8 string.
See Also
Source code in daft/expressions/expressions.py
2038 2039 2040 2041 2042 2043 2044 2045 2046 | |
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
2138 2139 2140 2141 2142 2143 2144 2145 2146 | |
round #
round(decimals: Expression | int = 0) -> Expression
The round of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
627 628 629 630 631 632 633 634 635 | |
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
2148 2149 2150 2151 2152 2153 2154 2155 2156 | |
rstrip #
rstrip() -> Expression
Strip whitespace from the right side of a UTF-8 string.
See Also
Source code in daft/expressions/expressions.py
2018 2019 2020 2021 2022 2023 2024 2025 2026 | |
sec #
sec() -> Expression
The elementwise secant of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
697 698 699 700 701 702 703 704 705 | |
second #
second() -> Expression
Retrieves the second for a datetime column.
See Also
Source code in daft/expressions/expressions.py
1712 1713 1714 1715 1716 1717 1718 1719 1720 | |
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
1467 1468 1469 1470 1471 1472 1473 1474 1475 | |
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
957 958 959 960 961 962 963 964 965 | |
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
967 968 969 970 971 972 973 974 975 | |
sign #
sign() -> Expression
The sign of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
607 608 609 610 611 612 613 614 615 | |
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
1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 | |
sin #
sin() -> Expression
The elementwise sine of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
657 658 659 660 661 662 663 664 665 | |
sinh #
sinh() -> Expression
The elementwise hyperbolic sine of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
717 718 719 720 721 722 723 724 725 | |
skew #
skew() -> Expression
Calculates the skewness of the values from the expression.
See Also
Source code in daft/expressions/expressions.py
1153 1154 1155 1156 1157 1158 1159 1160 1161 | |
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
2701 2702 2703 2704 2705 2706 2707 2708 2709 | |
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
1968 1969 1970 1971 1972 1973 1974 1975 1976 | |
sqrt #
sqrt() -> Expression
The square root of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
637 638 639 640 641 642 643 644 645 | |
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
2218 2219 2220 2221 2222 2223 2224 2225 2226 | |
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
1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 | |
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
1838 1839 1840 1841 1842 1843 1844 1845 1846 | |
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
1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 | |
strip #
strip() -> Expression
Strip whitespace from both sides of a UTF-8 string.
See Also
Source code in daft/expressions/expressions.py
2028 2029 2030 2031 2032 2033 2034 2035 2036 | |
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
2198 2199 2200 2201 2202 2203 2204 2205 2206 | |
sum #
sum() -> Expression
Calculates the sum of the values in the expression.
See Also
Source code in daft/expressions/expressions.py
997 998 999 1000 1001 1002 1003 1004 1005 | |
tan #
tan() -> Expression
The elementwise tangent of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
677 678 679 680 681 682 683 684 685 | |
tanh #
tanh() -> Expression
The elementwise hyperbolic tangent of a numeric expression.
See Also
Source code in daft/expressions/expressions.py
737 738 739 740 741 742 743 744 745 | |
time #
time() -> Expression
Retrieves the time for a datetime column.
Source code in daft/expressions/expressions.py
1762 1763 1764 1765 1766 | |
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
2058 2059 2060 2061 2062 2063 2064 2065 2066 | |
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
1918 1919 1920 1921 1922 1923 1924 1925 1926 | |
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
1928 1929 1930 1931 1932 1933 1934 1935 1936 | |
to_kebab_case #
to_kebab_case() -> Expression
Convert a string to kebab case.
See Also
Source code in daft/expressions/expressions.py
2098 2099 2100 2101 2102 2103 2104 2105 2106 | |
to_snake_case #
to_snake_case() -> Expression
Convert a string to snake case.
See Also
Source code in daft/expressions/expressions.py
2078 2079 2080 2081 2082 2083 2084 2085 2086 | |
to_title_case #
to_title_case() -> Expression
Convert a string to title case.
See Also
Source code in daft/expressions/expressions.py
2118 2119 2120 2121 2122 2123 2124 2125 2126 | |
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
2711 2712 2713 2714 2715 2716 2717 2718 2719 | |
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
2068 2069 2070 2071 2072 2073 2074 2075 2076 | |
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
2108 2109 2110 2111 2112 2113 2114 2115 2116 | |
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
2088 2089 2090 2091 2092 2093 2094 2095 2096 | |
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
2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 | |
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
2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 | |
total_days #
total_days() -> Expression
Calculates the total number of days for a duration column.
See Also
Source code in daft/expressions/expressions.py
1908 1909 1910 1911 1912 1913 1914 1915 1916 | |
total_hours #
total_hours() -> Expression
Calculates the total number of hours for a duration column.
See Also
Source code in daft/expressions/expressions.py
1898 1899 1900 1901 1902 1903 1904 1905 1906 | |
total_microseconds #
total_microseconds() -> Expression
Calculates the total number of microseconds for a duration column.
See Also
Source code in daft/expressions/expressions.py
1868 1869 1870 1871 1872 1873 1874 1875 1876 | |
total_milliseconds #
total_milliseconds() -> Expression
Calculates the total number of milliseconds for a duration column.
See Also
Source code in daft/expressions/expressions.py
1858 1859 1860 1861 1862 1863 1864 1865 1866 | |
total_minutes #
total_minutes() -> Expression
Calculates the total number of minutes for a duration column.
See Also
Source code in daft/expressions/expressions.py
1888 1889 1890 1891 1892 1893 1894 1895 1896 | |
total_nanoseconds #
total_nanoseconds() -> Expression
Calculates the total number of nanoseconds for a duration column.
See Also
Source code in daft/expressions/expressions.py
1878 1879 1880 1881 1882 1883 1884 1885 1886 | |
total_seconds #
total_seconds() -> Expression
Calculates the total number of seconds for a duration column.
See Also
Source code in daft/expressions/expressions.py
1848 1849 1850 1851 1852 1853 1854 1855 1856 | |
try_compress #
try_compress(codec: COMPRESSION_CODEC) -> Expression
Compress or null if unsuccessful.
See Also
Source code in daft/expressions/expressions.py
1427 1428 1429 1430 1431 1432 1433 1434 1435 | |
try_decode #
try_decode(charset: ENCODING_CHARSET) -> Expression
Decode or null if unsuccessful.
See Also
Source code in daft/expressions/expressions.py
1397 1398 1399 1400 1401 1402 1403 1404 1405 | |
try_decompress #
try_decompress(codec: COMPRESSION_CODEC) -> Expression
Decompress or null if unsuccessful.
See Also
Source code in daft/expressions/expressions.py
1437 1438 1439 1440 1441 1442 1443 1444 1445 | |
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
1457 1458 1459 1460 1461 1462 1463 1464 1465 | |
try_encode #
try_encode(charset: ENCODING_CHARSET) -> Expression
Encode or null if unsuccessful.
See Also
Source code in daft/expressions/expressions.py
1387 1388 1389 1390 1391 1392 1393 1394 1395 | |
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
1752 1753 1754 1755 1756 1757 1758 1759 1760 | |
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
1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 | |
upper #
upper() -> Expression
Convert UTF-8 string to all upper.
See Also
Source code in daft/expressions/expressions.py
1998 1999 2000 2001 2002 2003 2004 2005 2006 | |
value_counts #
value_counts() -> Expression
Counts the occurrences of each distinct value in the list.
See Also
Source code in daft/expressions/expressions.py
2344 2345 2346 2347 2348 2349 2350 2351 2352 | |
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
1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 | |
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
2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 | |
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
2926 2927 2928 2929 2930 2931 2932 2933 2934 | |
video_metadata #
video_metadata() -> Expression
Gets metadata for a video file.
See Also
Source code in daft/expressions/expressions.py
2916 2917 2918 2919 2920 2921 2922 2923 2924 | |
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
1828 1829 1830 1831 1832 1833 1834 1835 1836 | |
year #
year() -> Expression
Retrieves the year for a datetime column.
See Also
Source code in daft/expressions/expressions.py
1788 1789 1790 1791 1792 1793 1794 1795 1796 | |
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
2984 2985 2986 2987 | |
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
3014 3015 3016 3017 3018 3019 3020 3021 | |
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
2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 | |
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 | |
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 #
visit(expr: Expression) -> R
Visit an arbitrary expression, invoking this visitor.
Source code in daft/expressions/visitor.py
50 51 52 | |
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
54 55 56 57 58 59 | |
visit_alias #
visit_alias(expr: Expression, alias: str) -> R
Visit an alias expression.
Source code in daft/expressions/visitor.py
71 72 73 74 | |
visit_cast #
visit_cast(expr: Expression, dtype: DataType) -> R
Visit a cast expression.
Source code in daft/expressions/visitor.py
76 77 78 79 | |
visit_coalesce #
visit_coalesce(args: list[Expression]) -> R
Visit a coalesce expression.
Source code in daft/expressions/visitor.py
86 87 88 89 | |
visit_col #
visit_col(name: str) -> R
Visit a col expression.
Source code in daft/expressions/visitor.py
61 62 63 64 | |
visit_function #
visit_function(name: str, args: list[Expression]) -> R
Visit a function call expression.
Source code in daft/expressions/visitor.py
81 82 83 84 | |
visit_lit #
visit_lit(value: Any) -> R
Visit a lit expression.
Source code in daft/expressions/visitor.py
66 67 68 69 | |