daft.functions.to_struct#
to_struct #
to_struct(*fields: Expression, **named_fields: Expression) -> Expression
Constructs a struct from the input expressions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fields | Expression | Expressions to be set as struct fields, using the expression name as the field name. | () |
named_fields | Expression | Expressions to be set as struct fields, using the keyword arg as the field name. | {} |
Returns:
| Type | Description |
|---|---|
Expression | An expression for a struct column with the input columns as its fields. |
Examples:
1 2 3 4 5 | |
╭──────────────────────────────╮
│ struct │
│ --- │
│ Struct[a: String, b2: Int64] │
╞══════════════════════════════╡
│ {a: a, │
│ b2: 2, │
│ } │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ {a: b, │
│ b2: 4, │
│ } │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ {a: c, │
│ b2: 6, │
│ } │
╰──────────────────────────────╯
(Showing first 3 of 3 rows) Source code in daft/functions/struct.py
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 74 75 | |