QuestionQ135

VerifiedDeveloping Apache Spark™ DataFrame/DataSet API Applications

Which of the following code blocks produces a DataFrame that contains only the rows from DataFrame storesDF where the value in column sqft is less than or equal to 25,000 OR the value in column customerSatisfaction is greater than or equal to 30?

Explanation

PySpark DataFrame.filter accepts a Boolean Column condition. Column predicates are combined with | for logical OR because Python’s or cannot be overloaded for PySpark Column objects. The <= and >= comparisons are evaluated before |, yielding the required inclusive OR condition.

Learn more

Community Discussion

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