DP-203 · Question #150
Drag and Drop Question You have an Apache Spark DataFrame named temperatures. A sample of the data is shown in the following table. You need to produce the following table by using a Spark SQL…
The correct answer is PIVOT; CAST. PIVOT is correct because it transforms row-level data into columns, which is exactly what's needed to convert temperature readings (stored as rows per category) into a wide-format table with each category as its own column. CAST is correct because the pivoted numeric values…
Question
Exhibit
Answer Area
Drag items
Correct arrangement
- PIVOT
- CAST
Explanation
PIVOT is correct because it transforms row-level data into columns, which is exactly what's needed to convert temperature readings (stored as rows per category) into a wide-format table with each category as its own column. CAST is correct because the pivoted numeric values need to be explicitly converted to the appropriate data type (e.g., CAST as INT or FLOAT) to ensure proper formatting in the output table. Together, PIVOT restructures the data shape and CAST ensures correct data typing.
Topics
Community Discussion
No community discussion yet for this question.
