Ultimate access to all questions.
Upgrade Now 🚀
Sign in to unlock AI tutor
You have a DataFrame df with a column transaction_date in timestamp format. How would you extract the year from this timestamp using Spark? Provide the code snippet.
df
transaction_date
A
df.withColumn('year', year('transaction_date'))
B
df.select(year('transaction_date'))
C
df.withColumn('year', extract('year', 'transaction_date'))
D
df.select(extract('year', 'transaction_date'))