Home / ML Associate practice test / Data Processing / Question

Databricks Machine Learning Associate · free practice question

A data scientist is building a PySpark MLlib preprocessing Pipeline for a dataset with three columns: annual_salary (double), years_experience (integer), and…

Exam-style question on Data Processing from the free ML Associate practice test, with the answer and a full explanation below.

Updated November 10, 2026

Data Processing

A data scientist is building a PySpark MLlib preprocessing Pipeline for a dataset with three columns: annual_salary (double), years_experience (integer), and job_title (string). They plan to use PySpark's Imputer class to handle missing values across all three columns in one step. What is an important limitation they must account for?

  1. AThe Imputer supports the 'mean' strategy alone, so median or mode values have to be computed with approxQuantile() or groupBy().agg() and applied with fillna() before the Pipeline is built
  2. BThe Imputer treats Python None as missing but skips NaN values in double columns, so NaN entries in annual_salary have to be converted to None with F.when() before the DataFrame is passed in
  3. CThe Imputer supports numeric types such as integer and double but not string or categorical columns, so job_title has to be handled separately with a different imputation approach
  4. DThe Imputer is a standalone utility that is not a valid Pipeline stage, so it has to be fitted and applied outside the Pipeline, and listing it in stages raises an error during Pipeline.fit()
  5. EThe Imputer casts double columns to integer when the computed surrogate is a whole number, so decimal values in annual_salary are truncated and the column loses precision after imputation
Answer & explanation

Correct answer: C

WHY C: The PySpark Imputer documentation explicitly states: 'The imputer does not support categorical features and possibly creates incorrect values for a categorical feature.' The job_title string column cannot be passed to the Imputer; it must be handled separately (for example by filling with the most frequent title using a custom approach or SQL).

WHY NOT A: PySpark's Imputer supports 'mean', 'median', and 'mode' strategies; all three are documented and implemented, so no manual computation is needed.

WHY NOT B: By default the Imputer treats both NaN and null/None as missing for float/double columns (the missingValue parameter defaults to NaN); it does not skip NaN values.

WHY NOT D: The Imputer is a standard MLlib Estimator and is fully compatible with Pipeline stages; it is commonly chained with StringIndexer, OneHotEncoder, and VectorAssembler.

WHY NOT E: The Imputer preserves the original data type of its input columns in the output; it does not cast between double and integer during imputation.

Take the full ML Associate practice test free →

Would you pass today?

This question is one of 45 in the free, timed Databricks Machine Learning Associate practice test. Take it and get a section-by-section score.

Start the free test →