Ultimate access to all questions.
Upgrade Now 🚀
Sign in to unlock AI tutor
Which code snippet correctly adds a new column 'discounted_price' to a Spark DataFrame 'spark_df', calculating it as 20% less than the 'price' column?
A
spark_df.addColumn('discounted_price', spark_df['price'] * 0.8)
B
ALTER TABLE spark_df ADD COLUMN discounted_price AS price * 0.8
C
spark_df.withColumn('discounted_price', col('price') * 0.8)
D
spark_df['discounted_price'] = spark_df['price'] * 0.8
E
spark_df.withColumn('discounted_price', spark_df('price') * 0.8)