Skip to content
LakeBench
ProblemsCommunityPricing
Sign inStart practicing

Safely parse a batch of numeric strings

Python data engineering interview problem. Difficulty: intermediate. Pattern: Strings. About 15 minutes. Part of the Pro drill bank.

A CSV column is supposed to be numeric but contains junk. Ingest should convert what it can and skip or default the rest without crashing the job.

Safely parse a batch of numeric strings.

Requirements

  • Valid numeric strings become numbers.
  • Invalid entries follow the tests (skip, None, or 0).

Constraints

  • values: list of strings.
  • Do not raise on a single bad value if the tests expect a list back.

Examples

Input: parse_numbers(['1', '2.5', 'no']) Output: {'ok': [1.0, 2.5], 'bad': ['no']} This input follows the stated rules and produces this output.

Topics: lakebench, python, error-handling.

More Python interview questions · All interview problems · Learn data engineering

intermediate

Safely parse a batch of numeric strings

Interview-style drill: Convert a list of strings to numbers, collecting which entries failed instead of crashing.

Safely parse a batch of numeric strings.