QuestionQ81

VerifiedData Processing

A data scientist wants to use Spark ML to impute missing values in the PySpark DataFrame features_df. They want to replace missing values in every numeric column in features_df with the median for its respective numeric column.

They developed the following code block to perform this task:

Question Image

The code block is not completing the task. Which reason explains why it is not performing the imputation?

Explanation

Spark ML Imputer is an Estimator that must be fitted on the DataFrame to compute the median surrogate value for each numeric input column. Calling fit(features_df) creates an ImputerModel; transform(features_df) must then be called on that fitted model to perform the replacements.

Learn more

Community Discussion

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