pyspark.sql.Column.getField

Column.getField(name)[source]

An expression that gets a field by name in a StructType.

New in version 1.3.0.

Examples

>>> from pyspark.sql import Row
>>> df = spark.createDataFrame([Row(r=Row(a=1, b="b"))])
>>> df.select(df.r.getField("b")).show()
+---+
|r.b|
+---+
|  b|
+---+
>>> df.select(df.r.a).show()
+---+
|r.a|
+---+
|  1|
+---+