QuestionQ280

VerifiedDeveloping Apache Spark™ DataFrame/DataSet API Applications

Which of the following code blocks returns a new DataFrame in which the managerNameLength column contains the number of characters in the managerName column of DataFrame storesDF? Assume that DataFrame storesDF is the only defined language variable.

Choose two
Explanation

PySpark's length function computes the character length of a string column and accepts either a Column expression or the column name as a string. Thus, both col("managerName") and "managerName" correctly identify the source column when passed to length; withColumn returns a new DataFrame containing the resulting column.

Learn more

Community Discussion

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