Converter tool

Outlier Detection for CSV and Excel

Flag outliers in the numeric columns of a CSV or XLSX with IQR fences, z-scores or the modified z-score, optionally within groups. See a box plot per column, read the reason for every flag and export only the flagged rows or the whole file with a flag column.

Step 1

Load your data

Outlier Detection for CSV and Excel

Operator: Abdulla Al Fahad. How tools are built and checked

An outlier is a value that sits far from the rest of its column. Sometimes it is the most interesting row in the file, a fraud attempt or a genuine record sale. More often it is a typo: an extra zero, a decimal in the wrong place, a unit entered in grams when everything else is in kilograms. This tool finds them in the numeric columns of a CSV or XLSX, tells you which rule caught each one, and exports the suspicious rows so they can be checked at the source.

It offers four rules instead of one because they disagree in useful ways. The classic box-plot fences, the z-score and the modified z-score each fail on a different kind of data, and seeing all three on the same column is the quickest way to learn which to trust. The tool does not delete or alter anything. It flags, explains and exports; the decision about what to do with an outlier stays with you. The Data Quality Profile tool also lists outliers as one line of a wider health check; this one is for the outliers alone, with four selectable rules, per-group fences, box plots and a flagged-rows export.

Key features

  • IQR fences at 1.5 and 3, z-score and modified z-score (MAD), any combination at once
  • Up to 30 numeric columns per run, each with its own statistics
  • Optional grouping column with separate fences for up to 60 groups
  • A box plot per column with the flagged points drawn as red dots
  • A reason for every flag naming the rule, the threshold and the value
  • Adjustable z-score and modified z-score thresholds
  • Export flagged rows only, or every row with Outlier, Outlier columns and Outlier reason added
  • XLSX export with column statistics and a settings sheet, all text cells protected against formula injection

Four detection rules, and when each one lies to you

Load a CSV, TSV or XLSX of up to 25 MB and 300,000 rows with a header row. Columns that are at least 90 percent numbers are offered, and anything that looks like an identifier (id, index, zip, phone, row, number) starts unticked so it does not flood the results. Numbers may carry thousands commas, a currency symbol, a trailing percent sign or accounting brackets, so (1,250.00) reads as minus 1250. Up to 30 columns can be checked at once. Blank cells are ignored silently; text in a numeric column is left out of the statistics and counted in a warning.

An optional grouping column splits each numeric column into separate groups, each judged against its own fences, up to 60 groups. This matters more than any other setting. Order amounts from a small region and a large one belong on different scales, and a value that is ordinary overall can be wildly out of place within its own group. A group needs at least four numeric values to be judged; smaller groups are reported as too few and nothing is flagged in them.

The four methods are IQR at 1.5 (a value below Q1 minus 1.5 IQR or above Q3 plus 1.5 IQR), IQR at 3 (the same with 3, for extreme values only), the z-score (the distance from the mean in sample standard deviations, flagged beyond 3 by default) and the modified z-score (0.6745 times the distance from the median over the median absolute deviation, flagged beyond 3.5, the cut-off Iglewicz and Hoaglin recommended). Quartiles use linear interpolation, the rule behind Excel's QUARTILE.INC, and the standard deviation divides by n minus 1. The thresholds for the two z-scores can be changed.

The export keeps your original columns and adds three: Outlier (yes or no), Outlier columns (which columns were flagged) and Outlier reason, which reads like "amount [North] = 980: above the 1.5 IQR upper fence 142.25, z-score 3.17, modified z 104.85". You can export only the flagged rows or every row with the flag. The XLSX version also holds a Column statistics sheet with the fences per group and a Settings sheet recording the methods and thresholds, so the check can be reproduced.

How it works

For each column and group the tool sorts the values, takes Q1 and Q3 by linear interpolation (position (n minus 1) times p), computes IQR as Q3 minus Q1 and builds the two sets of fences. The mean and sample standard deviation give the z-score limits. The median of the values and then the median of the absolute deviations from that median give the MAD.

The modified z-score of a value x is 0.6745 (x minus median) / MAD. The factor 0.6745 makes the MAD comparable to a standard deviation for normally distributed data. If more than half the values are identical the MAD is zero and the division fails, so the tool falls back to the mean absolute deviation about the median with the constant 0.7979 and says so in a warning. A column with no spread at all flags nothing.

There is a hard limit on the plain z-score that the tool warns about. In a group of n values no point can have a z-score above (n minus 1) / the square root of n. With 10 values that ceiling is 2.85, so a threshold of 3 can never flag anything however extreme the value is. The IQR and MAD rules have no such ceiling, which is one reason they are on by default.

Common use cases

  • Checking an invoice or order export for decimal and extra-zero typos before month-end reporting
  • Finding sensor readings that are physically impossible in a lab or IoT export, machine by machine
  • Screening survey numeric answers (age, income, hours worked) for entries that were joked or mistyped
  • Reviewing payroll or expense lines for amounts far from their department's normal range
  • Preparing data for a model: seeing how many values each rule would trim before choosing a cut-off

How to use this tool

  1. Upload the file or click Load example, then tick the numeric columns to check. Identifier-like columns are unticked for you.
  2. Pick a grouping column if different segments have different normal ranges (region, product, machine).
  3. Choose methods. Start with IQR 1.5 and the modified z-score; add the z-score if you want to see how it compares.
  4. Download the flagged rows for review, or the whole file with the flag column to filter in your own spreadsheet.

Example

24 orders: two regions, one entry typo in each

order_id,region,amount,units
1001,North,118,3
... (12 North orders near 120, one of them 980 on order 1011)
... (12 South orders near 44, one of them 5 on order 1024 with units 38)

Ungrouped and grouped by region, IQR 1.5, z-score 3 and modified z 3.5

No grouping  amount: mean 117.92, SD 188.44, median 80, Q1 43.75, Q3 124.5, fences -77.38 to 245.63
             order 1011 amount 980: z 4.57, modified z 15.37 (flagged)
             order 1024 units 38: z 4.63, modified z 23.61 (flagged); amount 5 is NOT flagged
By region    South amount fences 32.5 to 54.5, so order 1024 amount 5 is flagged: z -3.03, modified z -8.66
             North amount fences 106.25 to 142.25, order 1011: z 3.17, modified z 104.85

Tips for best results

  • Group by anything that changes the normal level. In the example the South order of 5 is invisible overall, because the large North value inflates the fences, and obvious once each region has its own.
  • Trust the modified z-score over the plain z-score when you expect more than one outlier. The mean and standard deviation are both dragged by the outliers they are meant to detect, so a z-score of 3 can miss a value that the MAD rule scores at 15.
  • Use IQR 3 as a second pass. Values beyond 1.5 IQR are unusual; values beyond 3 IQR are very probably errors, and that short list is the one to send for correction first.
  • Run the grouped and ungrouped versions on one column and compare. Rows flagged only when grouped are local anomalies; rows flagged both ways are anomalies on any view.

Common pitfalls

An outlier is not an error. A genuine large customer will be flagged as faithfully as a typo, so every flag needs a decision, not an automatic delete.

Fences assume one cluster of values. A bimodal column (retail and wholesale prices together) will have fences that fit neither group; split it with the grouping column.

Skewed data produces many upper-side flags. Revenue, claim sizes and durations are right-skewed, so a long tail of flagged values may be normal for them. Consider checking log values by converting the column first.

Small groups give wide, unstable fences. A group of four values will rarely flag anything, and a group of five can flag a perfectly ordinary value. Do not read much into groups below about 10.

Common errors and how to fix them

"No numeric column was found"
The values are probably stored as text with units or spaces (12 kg, 1 250). Remove the unit text or clean the column first; thousands commas and currency symbols are accepted.
"The grouping column has N distinct values"
A column with more than 60 distinct values is probably an identifier or a free-text field. Choose a category such as region or product line.
Nothing is flagged but there is an obvious bad value
Check the group size. Groups under 4 values are skipped, and with the z-score alone a group of 10 can never reach 3. Switch on the IQR or modified z-score method.

Best practices

  • Correct values at the source system, then re-export, instead of editing the flagged file by hand.

Why the plain z-score missed the South order

In the example the amount column across both regions has a mean of 117.92 and a standard deviation of 188.44, because one 980 stretches both. A South order of 5 sits only 0.6 standard deviations below that mean, so it passes every global rule: the lower IQR fence is minus 77.38. Group the same column by region and South's own fences run from 32.5 to 54.5, which puts 5 well outside, with a modified z-score of minus 8.66.

That is masking: outliers in the data hiding other outliers by inflating the spread. It is the main reason to prefer rules built on medians and quartiles, and the main reason to group. The reverse also happens, which is why the comparison is worth making: the North 980 has a z-score of only 3.17 within its group, because in a group of 12 the highest possible z is 3.18.

Frequently asked questions

Which method should I use?

For a first look, IQR at 1.5 together with the modified z-score. They both use medians or quartiles, so one extreme value cannot hide itself. Use the plain z-score only for large, roughly bell-shaped groups.

Why does the modified z-score use 3.5?

Iglewicz and Hoaglin suggested flagging modified z-scores above 3.5 as potential outliers, and it is the value the literature repeats. It is editable if you want a stricter or looser rule.

Does it remove the outliers from my file?

No. It adds Outlier, Outlier columns and Outlier reason to a copy for download, or exports only the flagged rows. Your uploaded data is never modified.