Exam Preparation Quiz

Question 49 of 75

Transform String Column to Integer in PySpark DataFrame

You are working for MDFT Pro, a well-known training agency. You are building a solution using a Fabric notebook. You have a Spark DataFrame assigned to a variable named df. The DataFrame returns four columns.

You need to change the DataFrame as follows:

Which PySpark code should you use to achieve the goal?

Choose the correct answer from the options below.

Explanations for each answer:

Learn more about the withColumn() function in PySpark:
WithColumn Function
Next Question