Data Cleaning Basics: Missing Values, Duplicates and Outliers

Learn how to handle missing values, duplicates and outliers so your analysis rests on reliable data, with a simple step-by-step cleaning routine.

Share on Linkedin Share on WhatsApp

Estimated reading time: 7 minutes

Article image Data Cleaning Basics: Missing Values, Duplicates and Outliers

Ask any analyst where their time goes, and many will say the same thing: cleaning data. Charts and models get the attention, but they are only as trustworthy as the table underneath them. A single duplicated row, a blank cell treated as zero or a typo in a category label can quietly change a result. This guide walks through the three most common problems, which are missing values, duplicates and outliers, and gives you a routine you can apply to almost any dataset.

Start by looking before you fix

Cleaning should begin with inspection. Before changing anything, answer a few basic questions about the dataset: How many rows and columns does it have? What type is each column (number, text, date)? What is the range of each numeric column? How many blanks does each column contain? Most tools make this easy, whether you use a spreadsheet, SQL, Python with pandas, R or a business intelligence platform.

It also helps to keep the original file untouched. Work on a copy, or better, write your cleaning steps as a script or a recorded query, so the process can be repeated and reviewed. A cleaning step that nobody can reproduce is a risk for the whole team.

Missing values

Missing data appears as empty cells, the word “N/A”, a dash or placeholder numbers such as 0 or 9999. The first task is to find all the ways missingness is written in your data and standardize them. Then ask why the values are missing, because the reason affects the best response.

A customer may have skipped an optional form field, a sensor may have failed for an hour, or a system may have started collecting a field only recently. Each case calls for a different decision. Common options include:

  • Remove the rows when only a small share is affected and the loss will not bias the result.
  • Remove the column when most of its values are missing and it adds little.
  • Fill with a typical value, such as the median for numbers or the most frequent category for text, when you need to keep the row.
  • Fill using context, such as carrying the previous value forward in a time series, when that is logically justified.
  • Keep the blank as its own category when the absence itself carries meaning.

Whatever you choose, document it. Filling gaps with an average can shrink the natural variation in the data, so mention the method when you share results.

Duplicates

Duplicate records inflate totals and distort averages. They often come from merging files, importing the same export twice or a customer registering more than once. There are two kinds to watch for.

Exact duplicates are rows that match in every column and can be removed safely. Near duplicates are trickier: “Maria Silva” and “maria silva ” with a trailing space, or the same address written with and without abbreviations. Standardizing text before comparing helps a lot. Trim extra spaces, convert to a consistent case, and unify date and phone formats. After that, define what makes a record unique, such as a customer ID or the combination of email and order date, and check for repeats on that key.

Outliers

An outlier is a value far from the rest. It might be an error, such as a price entered with an extra zero, or a real but rare event, such as a very large purchase. Deleting every unusual value is a mistake, because some of the most important insights hide there.

Two simple detection methods are widely used. The first is visual: a box plot or histogram quickly shows values that stand apart. The second is the interquartile range rule, which flags values below the first quartile minus 1.5 times the IQR or above the third quartile plus 1.5 times the IQR. Neither method tells you whether a value is wrong, only that it deserves a look. Check the source, compare with business knowledge, and then decide whether to correct, cap, keep or remove it.

ProblemTypical signCommon response
Missing valuesBlanks, “N/A”, 0 or 9999 used as placeholdersStandardize, then remove, fill or label
Exact duplicatesIdentical rows after a merge or importRemove extra copies
Near duplicatesSame entity with different spelling or spacingStandardize text, then match on a key
OutliersValues far from the bulk of the dataInvestigate, then correct, cap, keep or remove
Inconsistent typesNumbers stored as text, mixed date formatsConvert to a single format

A simple cleaning routine

  1. Keep a copy of the raw data and work on a separate version.
  2. Profile the dataset: size, column types, ranges and blank counts.
  3. Fix data types so numbers, dates and text are stored correctly.
  4. Standardize text: trim spaces, unify case and merge spelling variants.
  5. Handle missing values with a documented rule for each column.
  6. Remove duplicates based on a clearly defined key.
  7. Investigate outliers and decide case by case.
  8. Validate the result by comparing row counts and totals before and after.
  9. Record every step so someone else can repeat it.

Common mistakes to avoid

One frequent mistake is cleaning without a question in mind. A field that looks messy may be irrelevant to your analysis, and time spent on it is wasted. Another is overwriting the original file, which makes it impossible to trace an error back to its source. A third is removing data silently: if a quarter of the rows disappear during cleaning, readers of your report deserve to know. Finally, remember that cleaning is not a one-time event. New data arrives with new problems, so building checks into your regular workflow pays off.

Conclusion

Good analysis begins with trustworthy data. By inspecting first, handling missing values with intention, removing duplicates carefully and treating outliers as questions rather than errors, you protect every chart and model built afterward. If you want to practice these skills with real tools, explore the data science and business intelligence courses on Cursa, which cover spreadsheets, SQL, visualization and analytical thinking step by step.

NTFS, exFAT, FAT32 and APFS: Choosing the Right File System for a Drive

Understand what a file system does and how NTFS, exFAT, FAT32, APFS and ext4 differ, so you can format drives without losing compatibility.

Text Encoding Explained: ASCII, Unicode and Why You Sometimes See Strange Symbols

Learn how computers store text, what ASCII and Unicode actually are, why UTF-8 became the standard, and how to fix files that display garbled characters.

Idempotency in APIs: Why Retrying a Request Should Be Safe

Learn what idempotency means in backend development, which HTTP methods provide it, and how idempotency keys prevent duplicate operations.

What Is a CDN? How Content Delivery Networks Make Websites Fast

Learn what a CDN is, how edge caching and cache headers work, what a cache hit means, and when a CDN helps — or does not.

Semantic Versioning Explained: What a Number Like 2.4.1 Actually Tells You

MAJOR.MINOR.PATCH is a promise, not decoration. Learn to read version numbers and understand dependency range symbols.

What Is a Virtual Machine? Virtualization Explained for Beginners

Learn what a virtual machine is, how hypervisors work, how VMs differ from containers, and when to use each one.

How HTTPS Works: Certificates, the TLS Handshake and What the Padlock Really Means

A beginner-friendly walkthrough of HTTPS: what TLS certificates prove, how the handshake works, and what the browser padlock does not guarantee.

Big O Notation Explained: How to Talk About Code Efficiency

A beginner-friendly guide to Big O notation: what it measures, the most common complexity classes, and how to reason about the cost of your code.