QuestionQ121

VerifiedDeveloping Apache Spark™ DataFrame/DataSet API Applications

Which of the following code blocks returns a DataFrame containing only 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?

Explanation

In the PySpark DataFrame API, combining two column-based filter conditions with logical AND requires wrapping each column reference in col() and joining the conditions with the bitwise & operator rather than Python's 'and'/'or' keywords, since Column objects override & and | for boolean logic but cannot be evaluated with Python's native boolean operators.

Learn more

Community Discussion

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