QuestionQ125

VerifiedDeveloping Apache Spark™ DataFrame/DataSet API Applications

The code block below must return a new DataFrame from DataFrame storesDF, with column storeId having the type string. Choose the response that correctly completes the numbered blanks in the code block to accomplish this task.

Code block:

storesDF.__1__("storeId", __2__("storeId").__3__(__4__)  
Explanation

PySpark DataFrame.withColumn returns a new DataFrame and replaces an existing column of the same name. col("storeId") produces the column expression, and cast(StringType()) converts that expression to the Spark string data type.

Learn more

Community Discussion

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