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.
Changed in version 3.4.0: Supports Spark Connect.
- Parameters
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| +---+