How do we compute and append an annual bonus column to an employee compensation DataFrame?
withColumn(colName, colExpr) returns a new DataFrame with an added or replaced column computed from an expression.
Feature engineering, financial calculations, data enrichment, and derived metric computation.
from pyspark.sql.functions import col
df = df.withColumn("annual_bonus", col("salary") * 0.15)Practice typing production-grade PySpark code for Adding Columns with withColumn().