
Ultimate access to all questions.
The following code block contains an error. It is intended to return a DataFrame with a column "dayOfYear" representing the day of the year (as an integer) derived from the "openDate" column in DataFrame "storesDF". Identify the error.
Note: The "openDate" column is of type integer and stores dates in UNIX epoch format (seconds since midnight on January 1, 1970).
Sample of storesDF:
| storeId | openDate |
|---|---|
| 0 | 1100746394 |
| 1 | 1474410343 |
| 2 | 1116610009 |
| 3 | 1180035265 |
| 4 | 1408024997 |
Code block:
storesDF.withColumn("dayOfYear", dayofyear(col("openDate")))
storesDF.withColumn("dayOfYear", dayofyear(col("openDate")))
A
The dayofyear() operation cannot extract the day of year from a column of type integer – column openDate must first be converted to type Timestamp.
B
The dayofyear() operation takes a quoted column name rather than a Column object as its first argument – the first argument should be "openDate".
C
The dayofyear() operation cannot extract the day of year from a column of type integer – column openDate must first be converted to type Date.
D
The dayofyear() operation is not applicable in a withColumn() call – the newColumn() operation must be used instead.
E
There is no dayofyear() operation – the day of year number must be extracted using substring utilities.