skip to content

A conversion of a text column to numbers meets 40 unparseable values in 100,000 — how does coercing rather than refusing change where they surface?

level: middleimportance: should knowfreq 64%

answer

  1. the conversion must decide something
  2. absence or a stop at that line
  3. distance from the line to the discovery
  4. coercing destroys the offending text
  5. defaults differ between designs

basics

~20 s

Coercing turns the 40 unparseable values into absence and lets the pipeline continue, so the loss surfaces much later as a figure nobody can explain. Refusing stops at the conversion line, with the offending values still in front of you.

solid answer

~50 s

A re-typing step — an operation whose only job is to hand back the same values in a different representation — has to decide what to do with a value that will not convert. Coercing turns it into absence; refusing stops the program at that line. The difference is not correctness but **distance**: coercing moves the discovery of those 40 values from the conversion to wherever someone finally notices a figure that is off, which may be a month and four steps away. Refusing keeps discovery at the line that has the offending text in hand. Choose per conversion, not globally: refuse where every value is supposed to parse and any exception is a defect, and coerce only where a small share is genuinely expected not to parse and you will look at how many became absent before moving on.

go deeper

for a junior

Know that a conversion has to do something with a value it cannot convert, and that the two usual choices are turning it into absence or stopping there. Know that the first one keeps running and the second one does not.

for a middle

Explain the choice as distance: coercing moves discovery downstream to whoever notices a wrong figure, refusing keeps it at the line holding the offending text. Say which default your tools take rather than assuming they agree.

for a senior

Demonstrate that you pick per conversion and that coercing is only honest when the count of failures is looked at. Be able to describe the failure where a column silently goes wholly absent after an upstream change.

for a principal

The standing call is which disposition your team's steps default to, and what that costs at three in the morning. Weigh a stopped run over one bad row against a quiet loss nobody finds for a month.

## The decision a conversion cannot avoid A **re-typing step** is an operation whose only job is to hand back the same values in a different representation — text to numbers, in this case. It is one of the few operations in this whole subject that is guaranteed to meet data it cannot handle, because the values were free-form until the moment you asked them to be numbers. So every such operation carries a disposition for a value that will not convert, whether you chose it or took the default. The two dispositions in common use are: - **Coercing** — the unparseable value becomes absence, the conversion succeeds, and the program carries on. Forty rows out of a hundred thousand now hold nothing instead of a number. - **Refusing** — the conversion stops at that line, naming the value it could not handle. No table comes back. A third exists and is worth knowing about because it is the hardest to detect: a few designs substitute a **default**, typically zero, rather than absence. That is worse than either of the above, because a substituted zero is indistinguishable from a real zero and there is nothing left to count. And at the other extreme, some designs offer no coercing mode at all and force you to filter or repair before converting, which is a refusal by another route. ## What actually differs: distance, not correctness Neither disposition is right in the abstract. What separates them is **how far the discovery of a bad value travels from the line that produced it**. | | Coercing | Refusing | |---|---|---| | Where the 40 values are noticed | wherever a figure finally looks wrong | at the conversion, immediately | | What you still have when you notice | absence, with the original text gone | the offending text itself | | Who notices | often a reader of the report | the person running the code | | Cost of a false alarm | none, the run continues | a stopped run over one bad value | | Failure mode | silent, cumulative | loud, immediate, sometimes over-eager | Coercing is not a shortcut and refusing is not rigour. Coercing is a decision that the pipeline's job is to keep running and that a known, small share of unconvertible values is part of the data's nature. Refusing is a decision that every value was supposed to parse and any that does not is a defect somewhere upstream. ## When coercing is the honest call 1. **The unparseable share is expected and bounded.** A free-text field that has always carried a few dashes and blanks is not a defect; it is the field. 2. **You look at the count.** Coercing is defensible only if the number of values that became absence is something a human sees before the result is used. Coercing and not counting is how a field that quietly went 100% unparseable after an upstream change produces an empty column and no alarm at all. 3. **The alternative is worse.** A nightly run stopped by one malformed value out of a million, at three in the morning, with nobody to look at it, is a real cost and not an imaginary one. ## When refusing is the honest call 1. **Every value is supposed to parse.** A column produced by another step in your own code has no business containing text that will not convert, so if it does, something earlier is broken and you want to know now. 2. **The values matter individually.** If the 40 rows are the ones the report is about, turning them into absence has changed the answer rather than degraded it. 3. **You are still developing.** During development a refusal is free information; you can always soften it once you know what the data actually contains. ## The part candidates miss The disposition is a property of the conversion you wrote, not a global setting for the pipeline, and it is entirely reasonable for one step to refuse and the next to coerce. What is not reasonable is not knowing which one you took. Most conversions have a default disposition, and defaults differ between designs — some refuse by default and make you opt into coercing, others coerce by default and make you opt into refusing. A candidate who says "it just turns them into missing values" has described one design's default and is going to be surprised by the other. The second thing candidates miss is that a coercing conversion destroys evidence. Once the text is gone, the only fact remaining is that something was absent, and you cannot answer the question everyone asks next — *what were those forty values?* If you coerce, the time to look at the offending values is before the conversion, not after. ## What an interviewer is listening for That you name both dispositions, that you frame the choice as where the discovery happens rather than as strict against lenient, and that you say out loud which default your tools take instead of assuming everyone's is the same.

  • A conversion refused on one malformed value out of a million and stopped the nightly run. Was that the right outcome?
    It depends entirely on whether that column was supposed to be fully parseable. If it was produced by your own earlier step, then yes — one bad value means something upstream is broken and the stop is the cheapest possible signal. If the column has always carried a trickle of free text, refusing was the wrong disposition and the fix is to coerce and count, not to retry the run.
  • You coerced, and later find the column is now entirely absent. What went wrong and how would you have caught it sooner?
    Something upstream changed the values' shape, and the coercing conversion faithfully turned every one of them into absence without complaint. Coercing only stays honest when the count of values that failed to convert is looked at as part of the step — a share that jumps from a handful to everything is the signal, and it is available at the conversion long before any figure looks wrong.

saying these in an interview costs you the question

  • Says a conversion simply turns bad values into missing ones
  • Treats coercing as the lenient option and refusing as rigour
  • Assumes every tool takes the same default disposition
  • Coerces without ever counting how many values converted
  • Thinks the original text can be recovered after coercing
  • Sets one disposition for a whole pipeline without looking