AP® Computer Science Principles · Big Idea 2 · Topic 2.3
Cleaning Data and Bias in Collection
Cleaning data makes messy entries consistent without changing their meaning, like merging NYC and New York into one label. Bias is different: it comes from who or what got sampled in the first place, and no amount of extra data from that same source fixes it.
A hundred thousand survey answers sound convincing, but if every answer came from the same narrow slice of people, the dataset describes that slice, not the population you meant to study. Size tells you nothing about who was left out. That is the core trap in this topic: a dataset can be huge, clean, and perfectly organized, and still be wrong about the world because of how it was collected.
Cleaning data is a separate job from fixing bias, and it happens first. Real-world data is messy: the same city typed as NYC, New York, new york, and N.Y. are four strings but one fact. Cleaning picks a single standard form and rewrites every variant to match it, so a computer counting by city doesn't split one place into four fake ones. Done right, cleaning never changes what an entry means, only how it's written, so the underlying information is preserved while becoming usable for sorting, grouping, and counting.
Bias is a different problem, and it lives upstream of cleaning. It comes from the sampling: which people, places, or conditions got recorded at all. A fitness app that only hears from owners of one expensive smartwatch is missing everyone else, and doubling its data just means more of that same narrow group, not a broader one. The same logic applies to sensors: if a thermometer fails on hot days, every hot day is underrepresented in the data, so conclusions drawn from it will quietly understate heat no matter how carefully the recorded numbers are cleaned.
Key terms
- Data cleaning
- The process of making inconsistent entries uniform, such as merging misspellings, without altering what they represent.
- Sampling bias
- A systematic skew that occurs when the data collected does not represent the full population or range of conditions.
- Standard value
- The single agreed-upon form that all equivalent but differently written entries get converted to during cleaning.
- Representativeness
- How well a dataset reflects the full population or situation it is meant to describe.
Watch it explained
- How it worksHow does cleaning data make entries uniform without changing what any of them mean?
- Worked exampleShow me cleaning a city column holding NYC, New York, new york, and N.Y. into one single value.
- Common mistakeWhy doesn't gathering more data fix a bias baked into how the data were collected?
- Going furtherWhat changes about your conclusions when the sensor collecting the data failed on hot days?
Check yourself
End of topic.