Databricks Certified Associate Developer for Apache Spark — Question 12
The code block shown below should create a single-column DataFrame from Python list years which is made up of integers. Choose the response that correctly fills in the numbered blanks within the code block to complete this task.
Code block:
_1_._2_(_3_, _4_)
Answer options
- A. 1. spark 2. createDataFrame 3. years 4. IntegerType
- B. 1. DataFrame 2. create 3. [years] 4. IntegerType
- C. 1. spark 2. createDataFrame 3. [years] 4. IntegertType
- D. 1. spark 2. createDataFrame 3. [years] 4. IntegertType()
- E. 1. spark 2. createDataFrame 3. years 4. IntegertType()
Correct answer: E
Explanation
The correct answer is E because it uses 'spark.createDataFrame' to create a DataFrame from the list 'years' and correctly calls 'IntegertType()' as the type for the column. Options A and C are incorrect due to the use of 'years' and '[years]' where the latter is not a valid argument for this context. Options B and D also fail because they incorrectly use 'DataFrame' instead of 'spark' and 'IntegertType' without parentheses, respectively.