Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Get an item from an array or map column.
Syntax
getItem(key)
Parameters
| Parameter | Type | Description |
|---|---|---|
key |
value | Index for array or key for map |
Returns
Column
Examples
df = spark.createDataFrame([([1, 2], {"key": "value"})], ["l", "d"])
df.select(df.l.getItem(0), df.d.getItem("key")).show()
# +----+------+
# |l[0]|d[key]|
# +----+------+
# | 1| value|
# +----+------+