Is there a way to flatten a struct
object in PySpark?
root
|-- key: struct (nullable = true)
| |-- id: string (nullable = true)
| |-- type: string (nullable = true)
| |-- date: string (nullable = true)
I found this SO post: How to flatten a struct in a Spark dataframe? to be similar, except I didn't know how to translate the answer(s) from Spark to PySpark.
SOLUTION: For others, here is the full code solution that I was looking for:
df.select(col("key.id"),
col("key.type"),
col("key.date"))