Column.
__getitem__
An expression that gets an item at position ordinal out of a list, or gets an item by key out of a dict.
ordinal
New in version 1.3.0.
Changed in version 3.4.0: Supports Spark Connect.
a literal value, or a slice object without step.
Column
Column representing the item got by key out of a dict, or substrings sliced by the given slice object.
Examples
>>> df = spark.createDataFrame([('abcedfg', {"key": "value"})], ["l", "d"]) >>> df.select(df.l[slice(1, 3)], df.d['key']).show() +------------------+------+ |substring(l, 1, 3)|d[key]| +------------------+------+ | abc| value| +------------------+------+