
Ultimate access to all questions.
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:
A sample of the storesDF data is:
| storeId | openDate |
|---|---|
| 0 | 1100746394 |
| 1 | 1474410343 |
| 2 | 1116610009 |
| 3 | 1180035265 |
| 4 | 1408024997 |
A
(storesDF.withColumn ('openDateFormat", col('openDate").cast('Date'))
withColumn("dayOfYear", dayofyear(col("openDateFormat"))))
(storesDF.withColumn ('openDateFormat", col('openDate").cast('Date'))
withColumn("dayOfYear", dayofyear(col("openDateFormat"))))
B
storesDF.withColumn(dayOfYear", get dayofyear(col(openDate)))
storesDF.withColumn(dayOfYear", get dayofyear(col(openDate)))
C
storesDF.withColumn("dayOfYear", dayofyear(col("openDate")))
storesDF.withColumn("dayOfYear", dayofyear(col("openDate")))
D
(storesDF.withColumn("openTimestamp", col("openDate"). cast("Timestamp"))
. withColumn("dayOfYear", dayofyear(col("openTimestamp))))
(storesDF.withColumn("openTimestamp", col("openDate"). cast("Timestamp"))
. withColumn("dayOfYear", dayofyear(col("openTimestamp))))
E
storesDF.withColumn("dayOfYear", substr(col("openDate'), 4, 6))
storesDF.withColumn("dayOfYear", substr(col("openDate'), 4, 6))