
Explanation:
The code block is intended to create a DataFrame from a list of integers, but it contains errors. The first error is that IntegerType is not called with parentheses, which is necessary because it's a class that needs to be instantiated. The second error is the absence of a column name, which is essential for defining the DataFrame's schema. Option A correctly identifies the need for a column name, and Option D correctly points out the missing parentheses for IntegerType. The other options either suggest incorrect solutions or are factually wrong regarding Spark's capabilities.
Ultimate access to all questions.
No comments yet.
Identify the error in the following code block intended to create a single-column DataFrame from a Python list years containing integers:
spark.createDataFrame(years, IntegerType)
spark.createDataFrame(years, IntegerType)
A
The column name must be specified.
B
The years list should be wrapped in another list like [years] to make clear that it is a column rather than a row.
C
There is no createDataFrame operation in spark.
D
The IntegerType call must be followed by parentheses.
E
The IntegerType call should not be present — Spark can tell that list years is full of integers.