Valid Databricks-Machine-Learning-Associate Dumps shared by ExamDiscuss.com for Helping Passing Databricks-Machine-Learning-Associate Exam! ExamDiscuss.com now offer the newest Databricks-Machine-Learning-Associate exam dumps, the ExamDiscuss.com Databricks-Machine-Learning-Associate exam questions have been updated and answers have been corrected get the newest ExamDiscuss.com Databricks-Machine-Learning-Associate dumps with Test Engine here:
A data scientist has a Spark DataFrame spark_df. They want to create a new Spark DataFrame that contains only the rows from spark_df where the value in column discount is less than or equal 0. Which of the following code blocks will accomplish this task?
Correct Answer: C
To filter rows in a Spark DataFrame based on a condition, the filter method is used. In this case, the condition is that the value in the "discount" column should be less than or equal to 0. The correct syntax uses the filter method along with the col function from pyspark.sql.functions. Correct code: from pyspark.sql.functions import col filtered_df = spark_df.filter(col("discount") <= 0) Option A and D use Pandas syntax, which is not applicable in PySpark. Option B is closer but misses the use of the col function. Reference: PySpark SQL Documentation