QuestionQ209

VerifiedDeveloping Apache Spark™ DataFrame/DataSet API Applications

The code block below contains an error. It is intended to return a DataFrame that contains every column from DataFrame storesDF except the sqft and customerSatisfaction columns. Identify the error.

Code block:

storesDF.drop(sqft, customerSatisfaction)  
Explanation

PySpark DataFrame.drop() can accept multiple column names in one call, but literal column names must be passed as strings. Without quotation marks, sqft and customerSatisfaction are interpreted as Python identifiers rather than the names of DataFrame columns.

Community Discussion

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