Which of the following code blocks returns a DataFrame containing only the rows from DataFrame storesDF where the value in column sqft is less than or equal to 25,000?
The correct code block to return a DataFrame containing only the rows from DataFrame storesDF where the value in column sqft is less than or equal to 25,000 is:
storesDF.filter("sqft <= 25000")
Option A incorrectly uses the wrong syntax for the filter condition, it should be "sqft <= 25000" instead of "sqft" <= 25000.
Option B uses the wrong operator (greater than instead of less than or equal to) and also needs to quote the column name as a string.
Option C uses square brackets instead of quotes to reference the column name, and also uses the wrong operator.
Option D uses the correct operator but needs to quote the column name as a string.
Option E uses the correct syntax, but needs to pass the column name as a string instead of using col("sqft").
Therefore, the correct answer is E.
storesDF.filter(col("sqft") <= 25000)
Option E, storesDF.filter(col("sqft") <= 25000), is the correct option. It uses the filter() operation with the condition col("sqft") <= 25000 to filter the rows where the value in the column sqft is less than or equal to 25,000.
upvoted 1 times
...
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
4be8126
Highly Voted 1 year, 7 months agoTmData
Most Recent 1 year, 5 months ago