Page 1 of 1

Which of the following code blocks returns a new DataFrame with a new column employeesPerSqft that is the quotient of co

Posted: Mon Mar 27, 2023 1:39 pm
by answerhappygod
Which of the following code blocks returns a new DataFrame with a new column employeesPerSqft that is the quotient of column numberOfEmployees and column sqft, both of which are from DataFrame storesDF? Note that column employeesPerSqft is not in the original DataFrame storesDF.

A. storesDF.withColumn("employeesPerSqft", col("numberOfEmployees") / col("sqft"))
B. storesDF.withColumn("employeesPerSqft", "numberOfEmployees" / "sqft")
C. storesDF.select("employeesPerSqft", "numberOfEmployees" / "sqft")
D. storesDF.select("employeesPerSqft", col("numberOfEmployees") / col("sqft"))
E. storesDF.withColumn(col("employeesPerSqft"), col("numberOfEmployees") / col("sqft"))