Certified Associate Developer for Apache Spark Practice Test

Certified Associate Developer for Apache Spark Practice Test practice questions, page 8 of 14, with answer review and explanations.

Question 36

Which of the following code blocks fails to return a DataFrame reverse sorted alphabetically based on column division?

  1. storesDF.orderBy("division", ascending – False)
  2. storesDF.orderBy(["division"], ascending = [0])
  3. storesDF.orderBy(col("division").asc())
  4. storesDF.sort("division", ascending – False)
  5. storesDF.sort(desc("division"))

Question 37

Which of the following code blocks returns a 15 percent sample of rows from DataFrame storesDF without replacement?

  1. storesDF.sample(fraction = 0.10)
  2. storesDF.sampleBy(fraction = 0.15)
  3. storesDF.sample(True, fraction = 0.10)
  4. storesDF.sample()
  5. storesDF.sample(fraction = 0.15)

Question 38

Which of the following code blocks returns all the rows from DataFrame storesDF?

  1. storesDF.head()
  2. storesDF.collect()
  3. storesDF.count()
  4. storesDF.take()
  5. storesDF.show()

Question 39

Which of the following code blocks applies the function assessPerformance() to each row of DataFrame storesDF?

  1. [assessPerformance(row) for row in storesDF.take(3)]
  2. [assessPerformance() for row in storesDF]
  3. storesDF.collect().apply(lambda: assessPerformance)
  4. [assessPerformance(row) for row in storesDF.collect()]
  5. [assessPerformance(row) for row in storesDF]

Question 40

The code block shown below contains an error. The code block is intended to print the schema of DataFrame storesDF. Identify the error. Code block: storesDF.printSchema

  1. There is no printSchema member of DataFrame – schema and the print() function should be used instead.
  2. The entire line needs to be a string – it should be wrapped by str().
  3. There is no printSchema member of DataFrame – the getSchema() operation should be used instead.
  4. There is no printSchema member of DataFrame – the schema() operation should be used instead.
  5. The printSchema member of DataFrame is an operation and needs to be followed by parentheses.