QuestionQ90

VerifiedDeveloping Apache Spark™ DataFrame/DataSet API Applications

The code block below must retrieve the integer value of the sqft column from the first row of the DataFrame storesDF. Choose the response that correctly supplies the numbered blanks in the code block to complete this task.

__1__.__2__.__3__[Int](__4__)  
Explanation

A Spark DataFrame is a Dataset[Row], and first returns its first Row. Row.getAs[Int] retrieves a field as an Int when passed that field’s name as a string, so the required expression is storesDF.first.getAs[Int]("sqft"). Spark Dataset ScalaDoc, Spark Row ScalaDoc

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!