
Explanation:
The correct answer is E. Here's the analysis:
col("sqft") to index a Row is invalid. Rows require column names as strings, not Column objects.[0] index-based access.collect(l) contains a typo (likely collect()[0]), but even if corrected, collect() retrieves all rows, which is inefficient for extracting a single row.first is a method and requires parentheses (first()) to invoke. Missing parentheses makes this syntax incorrect.first() to get the first Row and accesses the sqft column via dot notation, which is valid in PySpark for Row objects.Ultimate access to all questions.
Which of the following code blocks retrieves the value of the column sqft from the first row of the DataFrame storesDF?
A
storesDF.first()[col("sqft")]
B
storesDF[0]["sqft"]
C
storesDF.collect(l)[0]["sqft"]
D
storesDF.first.sqft
E
storesDF.first().sqft
No comments yet.