Saltar al contenido

Lección 6 · Collecting and Judging Data

Data Quality: Can You Trust the Values?

Check data quality using accuracy, completeness, consistency, validity, uniqueness and timeliness, with runnable checks for errors, duplicates and gaps.

A calculation is only as good as the values that go into it. Data quality is about whether data is fit for the purpose you have in mind. Perfect data hardly exists. The useful question is: are the problems small enough, and well enough understood, for this decision? A list that is fine for estimating foot traffic may be far too weak for billing customers.

Six common dimensions

Many organizations describe quality with a handful of dimensions. Names vary, but these ideas appear often.

Is it right?

Accuracy Matches reality
Validity Follows the rules
Uniqueness No accidental copies
1 / 2
  • Accuracy: does the value match what really happened? A birth year typed as 1987 instead of 1978 is valid in form but inaccurate.
  • Validity: does the value follow the rules? A date such as 2026-02-30 or an age of -4 is invalid.
  • Completeness: are the values you need present?
  • Consistency: do related values agree? If one system says an order was shipped and another says it was canceled, something is wrong.
  • Uniqueness: is each real thing recorded once?
  • Timeliness: is the data recent enough? A price list from last year may be accurate history but a poor basis for today's quote.

Accuracy is often the hardest to check, because you need something to compare with, such as the original document or a fresh measurement.

Check a small dataset

The program below looks at a tiny, deliberately messy list of event sign-ups. Run it, then read the findings.

Python Run simple quality checks

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The checks find a blank email, an impossible age, a date that does not exist, a repeated email hidden by capital letters and three spellings of Peru. Notice that rows 1 and 4 share an email but list different countries. A computer cannot know which is right. It could be one person who moved, a shared family address or a typing error. Find out before you delete or merge.

Missing data has reasons

Ask why values are missing, because the reason affects the results.

  • Missing by chance, such as a few forms lost in the mail, may do little harm if the number is small.
  • Missing for a reason related to the answer is dangerous. If unhappy customers skip the satisfaction question, the average of the remaining answers looks too good.

Common choices are to keep the gap and report it, to remove incomplete rows, or to estimate values (imputation). Every choice changes something. Removing rows can remove a whole group. Filling in the average makes the data look less varied than it is. Say what you did and how many values were affected.

Outliers are not automatically errors

An outlier is a value far from the others. A height of 17 meters for a person is surely a mistake. A very large order might be real and important. Check the source. Remove a value only when you have a good reason, and record it.

Measure the quality

Simple measures make problems visible and let you track them over time:

Check Example measure
Completeness Share of rows with an email
Validity Share of dates that parse
Uniqueness Number of repeated IDs
Timeliness Days since the last update
Consistency Number of records that disagree between systems

Set a target that matches the use. A mailing list may need almost every address to be valid. A rough trend report may accept a few gaps if they are explained.

Fix problems at the source

Cleaning data after the fact is repeated work. Better prevention includes dropdown lists for fixed choices, required fields only where truly needed, date pickers, range limits and clear instructions for the people typing. Be careful with strict rules: if a form refuses a real but unusual name, people may type something false just to continue.

Keep a cleaning log: what you found, what you changed, how many rows were affected and why. It makes your work checkable.

Decide what is good enough

You will never clean everything, so match effort to risk. Ask what happens if a value is wrong. A misspelled city in a rough marketing chart is a small nuisance. A wrong dosage, bank amount or delivery address can cause real harm. Spend the most care where errors are costly or hard to undo.

It helps to agree on a short quality rule list with the people who use the data. For the sign-up example it might say: every row needs an email; ages must be between 0 and 120; dates must be real; country must come from an approved list; and each email appears once unless the organizer confirms two people share it. Rules that are written down can be run again next month, and anyone can see why a row was flagged.

Finally, report quality with your results. A line such as "3% of rows had no country and are excluded from the country chart" takes little space and tells readers how far to trust the picture. If the excluded share is large, say so first, because it may change what the result means.

Review the list from time to time, because a rule that made sense last year may no longer fit the way people use the data.

Do not silently delete inconvenient rows. Removing the values that disagree with what you hoped to find is a way of changing the result, even if each removal feels reasonable.

Check your understanding

Quick check · 4 questions

of 4 answered You scored / 4 · perfect!

  1. 1. A customer's birth year is stored as a possible but wrong year. Which dimension fails?

    The value follows the rules, so it is valid in form, but it does not match reality.
  2. 2. Why is it risky that unhappy customers skip a rating question?

    When missingness depends on the value, the remaining data no longer represents everyone.
  3. 3. You find one order far larger than all others. What is the best first step?

    Outliers may be real. Investigate, and record any decision you make.
  4. 4. Which is a prevention step rather than a cleanup step?

    Controls at the point of entry stop many errors from being created.

Summary

  • Quality means fit for a specific purpose.
  • Check accuracy, validity, completeness, consistency, uniqueness and timeliness.
  • Learn why data is missing before you handle it.
  • Investigate outliers and conflicting duplicates instead of guessing.
  • Prevent errors at entry and keep a log of changes.

Next: Evaluating Data Sources

Tu progreso se guarda en este navegador. No necesitas una cuenta.