DATABRICKS-CERTIFIED-ASSOCIATE-DEVELOPER-FOR-APACHE-SPARK · Question #75
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…
The correct answer is D. 1. storesDF. The code pattern __1__.__2__.__3__Int maps to storesDF.first().getAsInt. Here: first() retrieves the first Row object from the DataFrame, and getAsInt extracts the value of the sqft column from that Row, casting it to an integer. The type parameter [Int] is required to specify…
Question
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.3Int
Options
- A
- storesDF
- B
- storesDF
- C
- storesDF
- D
- storesDF
How the community answered
(34 responses)- A9% (3)
- B3% (1)
- C3% (1)
- D85% (29)
Explanation
The code pattern __1__.__2__.__3__[Int](__4__) maps to storesDF.first().getAs[Int]("sqft"). Here: first() retrieves the first Row object from the DataFrame, and getAs[Int]("sqft") extracts the value of the sqft column from that Row, casting it to an integer. The type parameter [Int] is required to specify the return type at the call site. Option D is the only choice that correctly chains first(), then getAs[Int], passing the column name as a string argument.
Topics
Community Discussion
No community discussion yet for this question.