QuestionQ87

VerifiedDeveloping Apache Spark™ DataFrame/DataSet API Applications

A data scientist is working with a Spark DataFrame named customerDF that contains customer information. The DataFrame includes an email column containing customer email addresses. The data scientist needs to divide this column into username and domain parts.

Which code snippet divides the email column into username and domain columns?

Explanation

PySpark split separates a string column into an array using the specified regular-expression delimiter. With @ as the delimiter, array element 0 is the text before @ and element 1 is the text after it; getItem retrieves those positions to create the username and domain columns.

Learn more

Community Discussion

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