QuestionQ28

VerifiedData Processing

A data scientist has a Spark DataFrame named spark_df. They need to create a new Spark DataFrame containing only the rows from spark_df for which the value in the discount column is less than or equal to 0.

Which of the following code blocks accomplish this task?

Choose two
Explanation

A Boolean expression such as spark_df["discount"] <= 0 can be used either as the condition supplied to DataFrame.filter() or directly in Spark DataFrame bracket indexing. Both forms return a DataFrame containing only rows for which discount is less than or equal to zero. PySpark SQL DataFrames do not use the pandas .loc indexer.

Learn more

Community Discussion

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