How do we group multiple related columns (street, city, zipcode) into a single nested address struct?
struct() bundles multiple column expressions into a composite StructType column.
Organizing hierarchical data models, preparing nested JSON payloads, and clean domain boundaries.
from pyspark.sql.functions import col, struct
df = df.withColumn("address", struct(col("street"), col("city"), col("zipcode")))Practice typing production-grade PySpark code for Creating Nested Structures with struct().