pyspark.sql.DataFrame.__getattr__

DataFrame.__getattr__(name: str) → pyspark.sql.column.Column[source]

Returns the Column denoted by name.

New in version 1.3.0.

Changed in version 3.4.0: Supports Spark Connect.

Parameters
namestr

Column name to return as Column.

Returns
Column

Requested column.

Examples

>>> df = spark.createDataFrame([
...     (2, "Alice"), (5, "Bob")], schema=["age", "name"])

Retrieve a column instance.

>>> df.select(df.age).show()
+---+
|age|
+---+
|  2|
|  5|
+---+