QuestionQ44

VerifiedDeveloping Apache Spark™ DataFrame/DataSet API Applications

Which of the following code blocks returns a new DataFrame from the DataFrame storesDF, with the modality column set to the constant string "PHYSICAL"? Assume storesDF is the only defined language variable.

Explanation

In PySpark, DataFrame.withColumn produces a new DataFrame and requires a Column expression as its value. lit("PHYSICAL") creates a Column whose value is the literal string PHYSICAL, so it correctly sets every modality value to that constant.

Learn more

Community Discussion

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