Build column expressions, chain immutable transformations, and know exactly which call makes Spark do the work.
Most DataFrame methods take columns, and PySpark gives you several ways to name one: a plain string, F.col("amount"), df["amount"] / df.amount (bound to that specific DataFrame — handy in joins), or a SQL snippet via F.expr / selectExpr.
A Column is an expression tree like amount * 1.2 that Spark evaluates later, inside the JVM. Operators (+, *, ==, &, |, ~) build bigger expressions and .alias() names the result. Python's precedence bites here: write (F.col("a") > 1) & (F.col("b") < 2) with the parentheses.
from pyspark.sql import functions as F
orders.select(
"order_id", # a column name
F.col("amount"), # a Column object
orders["country"], # bound to this DataFrame
(F.col("amount") * 1.2).alias("gross"), # an expression
F.expr("upper(status) AS status"), # SQL expression string
)
orders.selectExpr("order_id", "amount * 1.2 AS gross")Reach the last step for the run summary: the key takeaways from this lesson.