Duplicates and what they do to your sample
Tell true duplicates from repeated measures, remove them with a stated key, and see why they make results look too certain.
You will be able to
- Tell a duplicate record from a legitimate repeat
- Remove duplicates by a key you can defend
- Explain how duplicates shrink standard errors
Same row twice
ReadThe customer list has 612 rows. Insights shows Duplicate rows among the headline numbers on its Overview page.
Messy customer listA duplicate might be an export that ran twice, a merge that matched too much, or two real events that look alike. The first two are errors. The third is data. Only the data's story tells you which.
After removing them
PredictPredict first
12 of the customer list's rows repeat an earlier row in every column. How many rows are left after removing them?
Reveal
The answer: About 600
- Twelve extra rows look harmless, and at this size they mostly are. The danger comes from who the repeats are: if they all come from one source, that source now counts for more than it should.
Choose the key
In the appIn Prepare (⌘3), Remove duplicate rows keeps one row per combination of the columns you pick:
- Pick no columns to compare whole rows.
- Pick
customer_idto keep one row per customer. Check first that repeats of an id really are the same customer, since conflicting rows may hold information you want.
Remove near-duplicates finds text that is nearly the same, such as a name with a typo. Review those matches yourself.
Not every repeat is a duplicate
ReadTen patients each measured on three days give thirty rows. Those aren't duplicates, and deleting them destroys the design. Two identical readings from one instrument may be real too, especially with coarse rounding.
Why they make results look surer
ReflectThe standard error of a mean falls with the square root of the sample size. If every row appeared twice, you would report
That's about 30% narrower with no new information. Which result in your own work would you least want this to happen to?
Check your understanding
CheckpointCheck yourself
The customer list has 612 rows, and 12 of them repeat an earlier row. How many rows remain if you keep the first of each?
Show the answer
Answer: 600
612 − 12. Keep one of each, not none.
Check yourself
A study records blood pressure at morning and evening for each patient. A colleague proposes removing rows with a repeated patient id. What's wrong with that?
Show the answer
Answer: b
Rows sharing an id are duplicates only when one row per id is what the table is meant to hold.
Check yourself
An export bug doubled every row, and nobody noticed. What happens to a t test on this data?
Show the answer
Answer: b
The means stay the same, but the test believes it has twice as much evidence as it does.
Recap
Recap- A duplicate is a row that breaks your definition of one row.
- Remove by a key you can defend, and review near-matches yourself.
- Undetected duplicates make every result look more certain than it is.
Concepts in this lesson