Courseiva
Data Preparation for Machine LearningmediumMultiple ChoiceObjective-mapped

MLA-C01 Data Preparation for Machine Learning Practice Question

Exhibit

ProcessingJobError: Execution failed
Error: Traceback (most recent call last):
  File "/opt/ml/processing/input/code/preprocess.py", line 45, in <module>
    df['age'] = df['age'].apply(float)
ValueError: could not convert string to float: 'twenty-five'

Refer to the exhibit. A SageMaker Processing job fails with the following error log. Which change during data preparation would resolve the issue?

⚠ Common exam trap

Candidates often assume missing value handling (Option B) or column removal (Option C) is the fix, when the actual issue is a data type inconsistency that requires explicit type casting in the preprocessing code.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

Modify the preprocessing script to cast 'age' to float using astype(float)

The error log indicates a type mismatch when processing the 'age' column, likely due to mixed data types (e.g., strings and numbers) in a column expected to be numeric. By explicitly casting the column to float using astype(float) in the preprocessing script, you ensure consistent numeric type handling, which resolves the failure during SageMaker Processing job execution.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • In SageMaker Data Wrangler, set the 'age' column type to 'number'

    Why it's wrong here

    Data Wrangler’s type setting does not affect the actual data types parsed in the processing script.

  • Drop rows with missing values in the 'age' column before training

    Why it's wrong here

    Dropping rows does not fix the type error; the column still contains strings.

  • Remove the 'age' column from the dataset entirely

    Why it's wrong here

    This discards a potentially important feature.

  • Modify the preprocessing script to cast 'age' to float using astype(float)

    Why this is correct

    Casting the column ensures numeric operations work.

Visual reference

Client Recursive Resolver Root DNS (13 root servers) TLD DNS (.com, .org, …) Authoritative example.com query IP addr answer

About these practice questions

This MLA-C01 question is part of Courseiva's 835-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This MLA-C01 practice question is part of Courseiva's free Amazon Web Services certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the MLA-C01 exam.