daft.Expression.map.get

daft.Expression.map.get#

Expression.map.get(key: Expression) Expression[source]#

Retrieves the value for a key in a map column

Example

>>> import pyarrrow as pa
>>> import daft
>>> pa_array = pa.array([[(1, 2)],[],[(2,1)]], type=pa.map_(pa.int64(), pa.int64()))
>>> df = daft.from_arrow(pa.table({"map_col": pa_array}))
>>> df = df.with_column("1", df["map_col"].map.get(1))
>>> df.show()
╭───────────────────────────────────────┬───────╮
│ map_col                               ┆ 1     │
│ ---                                   ┆ ---   │
│ Map[Struct[key: Int64, value: Int64]] ┆ Int64 │
╞═══════════════════════════════════════╪═══════╡
│ [{key: 1,                             ┆ 2     │
│ value: 2,                             ┆       │
│ }]                                    ┆       │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
│ []                                    ┆ None  │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
│ [{key: 2,                             ┆ None  │
│ value: 1,                             ┆       │
│ }]                                    ┆       │
╰───────────────────────────────────────┴───────╯
Parameters:

key – the key to retrieve

Returns:

the value expression

Return type:

Expression