GARETH GRANTTECHNOLOGY · DATA · INNOVATION
Explore

02 / Data foundations

Data quality, missing values and outliers

Data cleaning establishes whether records are usable for a specific decision. An unusual observation is a prompt to investigate, not permission to remove inconvenient evidence.

FoundationLive exploration + Python

The business question

Is the apparent business problem real, or did the records create it?

  • Prevent unit errors, duplicate transactions and missing outcomes from distorting business measures.
  • Identify extreme delays or losses worth investigating without erasing genuine failures.
  • Document how exclusions or corrections affect a reported result.

How the method works

Data quality starts with business rules: a transaction identifier should be unique at transaction level, a completion time cannot precede its start, and a percentage should use an identifiable numerator and denominator. Keep a raw copy and create an analysis copy. Corrections need an explanation that another analyst can trace to a source record or a clear operational rule.

Missingness can change the meaning of a result. If only satisfied customers answer a survey, replacing unanswered ratings with the average does not recover the absent opinions. Examine who is missing, whether the absence itself carries information, and how a complete-case result differs from plausible alternatives. Imputation is a modelling choice with assumptions, not a way to manufacture observations.

An IQR screen flags values outside Q1 − 1.5 × IQR and Q3 + 1.5 × IQR. A flag is relative to the observed distribution; it does not establish that the value is wrong. Verify entries, inspect timestamps and classify known operating conditions. A valid breakdown delay may belong in a customer-experience analysis even when a separate routine-service study excludes breakdowns by a pre-agreed definition.

The calculation

IQR = Q3 − Q1; lower flag = Q1 − 1.5 × IQR; upper flag = Q3 + 1.5 × IQR
Read the symbols
SymbolMeaning
Q1, Q325th and 75th percentiles using a documented interpolation rule.
IQRSpread of the middle half of measured values.
flagA candidate for review, not an automatic rejection or correction.

A worked business example

ILLUSTRATIVE SCENARIO

Illustrative service desk: ten recorded job durations include a 60-minute repair. The analyst screens the data and then asks whether that long repair is an error or an operational event.

Inputs

  • Minutes: 10, 11, 11, 12, 12, 13, 13, 14, 15, 60.
  • Quartiles use NumPy’s default linear interpolation.

Work through the numbers

  1. Calculate Q1 = 11.25 and Q3 = 13.75 minutes. The IQR is 2.50 minutes.
  2. Compute the lower fence: 11.25 − 1.5 × 2.50 = 7.50 minutes. The upper fence is 13.75 + 3.75 = 17.50 minutes.
  3. Only 60 minutes lies outside the fences. The mean of all ten jobs is 171/10 = 17.10 minutes.
  4. For a sensitivity comparison only, the other nine average 111/9 = 12.33 minutes. The difference shows why the record matters; it does not justify deleting it.
One flagged duration, 60 minutes. Inclusive mean 17.10 min; sensitivity mean excluding that record 12.33 min.

If the 60-minute job was a genuine failure, it belongs in a measure of the customer’s overall experience. If source evidence proves that seconds were entered as minutes, correct the unit and retain an audit trail.

Explore the decision

Flag values for investigation. The live explorer has its own example inputs; it is separate from the worked calculation above.

Enable JavaScript to use this calculator. The worked example and executable Python remain available.

Apply it at work

  1. Define valid ranges, units, keys and the process population before editing data.
  2. Profile missing values, duplicate identifiers, impossible combinations and extreme observations.
  3. Investigate flagged rows against source evidence; record every correction, exclusion or unresolved issue.
  4. Compare results under defensible alternatives and state what the remaining data cannot establish.

Check these assumptions

  • The cleaning rules reflect the actual process and intended unit of analysis.
  • A duplicate key is interpreted in context: legitimate repeat visits are not duplicate customers.
  • Outlier fences are screening rules and can flag genuine observations in skewed distributions.
  • Any imputation or exclusion is disclosed and supported by a reason relevant to the decision.

Common mistakes and how to avoid them

  • Removing high costs solely because they worsen the result creates a biased business case.
  • Treating zero as missing can erase genuine zero sales or zero downtime.
  • Applying global fences across different product types can mislabel a legitimate high-value segment.

How this can help the business

  • Traceable cleaning can prevent an investment decision from being driven by a spreadsheet error.
  • Reviewing valid extreme cases can reveal service failures and hidden workload that ordinary averages miss.
A decision rule to adapt

Change a value only when evidence or the pre-defined analysis population supports the change; otherwise retain it and analyse its influence.

When to use another approach

Use robust summaries, separate operating regimes or a distribution suited to genuine skewness when extreme values are valid.

Reproduce the worked example in Python

The code is self-contained for this example. Dependencies and run instructions are included with the downloadable notebook.

Show executable code and recorded output
import numpy as np
minutes = np.array([10, 11, 11, 12, 12, 13, 13, 14, 15, 60])
q1, q3 = np.quantile(minutes, [0.25, 0.75])
iqr = q3 - q1
flagged = (minutes < q1-1.5*iqr) | (minutes > q3+1.5*iqr)
print(f'Flagging fences: {q1-1.5*iqr:.2f}, {q3+1.5*iqr:.2f} min')
print('Review these values:', minutes[flagged].tolist())
print(f'Inclusive mean: {minutes.mean():.2f} min')
print(f'Sensitivity mean only: {minutes[~flagged].mean():.2f} min')

Recorded output

Flagging fences: 7.50, 17.50 min
Review these values: [60]
Inclusive mean: 17.10 min
Sensitivity mean only: 12.33 min
Download all worked examples

Sources and further reading

Concepts are linked to primary teaching or technical sources. The business examples are illustrative applications, not reported client results.