Databricks Certified Associate Developer for Apache Spark — Question 157
The code block shown below should return a DataFrame containing only the rows from DataFrame storesDF where the value in column sqft is less than or equal to 25,000 AND the value in column customerSatisfaction is greater than or equal to 30. Choose the response that correctly fills in the numbered blanks within the code block to complete this task.
Code block:
storesDF.__1__(__2__ __3__ __4__)
Answer options
- A. 1. filter 2. (col("sqft") <= 25000) 3. & 4. (col("customerSatisfaction") >= 30)
- B. 1. filter 2. (col("sqft") <= 25000 3. & 4. col("customerSatisfaction") >= 30
- C. 1. filter 2. (col("sqft") <= 25000) 3. and 4. (col("customerSatisfaction") >= 30)
- D. 1. drop 2. (col(sqft) <= 25000) 3. & 4. (col(customerSatisfaction) >= 30)
- E. 1. filter 2. col("sqft") <= 25000 3. and 4. col("customerSatisfaction") >= 30
Correct answer: A
Explanation
Option A is correct because it uses the filter method along with the appropriate logical operator '&' to combine conditions on the sqft and customerSatisfaction columns. The other options contain syntax errors or incorrect logical operators that would prevent the code from executing correctly, such as missing parentheses or using 'and' instead of '&'.