nerdexam
Databricks

DATABRICKS-CERTIFIED-ASSOCIATE-DEVELOPER-FOR-APACHE-SPARK · Question #31

Which of the following code blocks returns a DataFrame containing a column dayOfYear, an integer representation of the day of the year from column openDate from DataFrame storesDF? Note that column op

Sign in or unlock DATABRICKS-CERTIFIED-ASSOCIATE-DEVELOPER-FOR-APACHE-SPARK to reveal the answer and full explanation for question #31. The question stem and answer options stay visible for context.

Perform Data Transformations using Spark DataFrame API

Question

Which of the following code blocks returns a DataFrame containing a column dayOfYear, an integer representation of the day of the year from column openDate from DataFrame storesDF? Note that column openDate is of type integer and represents a date in the UNIX epoch format - the number of seconds since midnight on January 1st, 1970. A sample of storesDF is displayed below:

Options

  • A(storesDF.withColumn("openTimestamp", col("openDate").cast("Timestamp"))
  • BstoresDF.withColumn("dayOfYear", get dayofyear(col("openDate")))
  • CstoresDF.withColumn("dayOfYear", dayofyear(col("openDate")))
  • D(storesDF.withColumn("openDateFormat", col("openDate").cast("Date"))
  • EstoresDF.withColumn("dayOfYear", substr(col("openDate"), 4, 6))

Unlock DATABRICKS-CERTIFIED-ASSOCIATE-DEVELOPER-FOR-APACHE-SPARK to see the answer

You've previewed enough free DATABRICKS-CERTIFIED-ASSOCIATE-DEVELOPER-FOR-APACHE-SPARK questions. Unlock DATABRICKS-CERTIFIED-ASSOCIATE-DEVELOPER-FOR-APACHE-SPARK for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.

Topics

#Spark DataFrame API#Date and Time Functions#Column Transformations#Epoch Time Handling
Full DATABRICKS-CERTIFIED-ASSOCIATE-DEVELOPER-FOR-APACHE-SPARK Practice