QuestionQ189

VerifiedDeveloping Apache Spark™ DataFrame/DataSet API Applications

Which of the following code blocks returns a DataFrame with a dayOfYear column: an integer representation of the day of the year from the openDate column in DataFrame storesDF?

Note that openDate is an integer column representing a date in UNIX epoch format—the number of seconds since midnight on January 1st, 1970.

A sample of storesDF is shown below:

Question Image

Explanation

dayofyear extracts an integer day-of-year from a date or timestamp. A Unix epoch value expressed in seconds must be converted to a timestamp before that extraction, so casting openDate to Timestamp and applying dayofyear produces the required column.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!