Exam Certified Associate Developer for Apache Spark All QuestionsBrowse all questions from this exam
Question 102

The code block shown below should extract the integer value for column sqft from the first row of DataFrame storesDF. Choose the response that correctly fills in the numbered blanks within the code block to complete this task.

Code block:

__1__.__2__.__3__[Int](__4__)

    Correct Answer: A

    To extract the integer value for column sqft from the first row of the DataFrame storesDF, we need to use the first() method to retrieve the first row as a Row object, then use the getAs method to access the value of the column. The correct code sequence is storesDF.first().getAs[Int]("sqft"), where storesDF is the DataFrame, first() retrieves the first row, getAs retrieves the value by column name, and "sqft" is the name of the column.

Discussion
Sowwy1Option: D

This is part of the official databricks exam samples. This is the correct answer: D.1. storesDF 2. first 3. getAs 4. "sqft"

thanabOption: A

A A is correct. D is incorrect. Option D is incorrect because it uses the first method without parentheses. The first method is a method of a DataFrame and must be called with parentheses to return the first row of the DataFrame. Here’s the corrected code block: ``` storesDF.first().getAsInt ```

carlosmps

on scala works

carlosmps

the using of first without parentheses

cookiemonster42Option: D

correct. we can use first and first() interchangeably, getAs works as getAs[int]("col_name")

newusername

could anyone show working test case ?