Min base_salary 15.15 in red next to 49,479 yearly rows in green: 521 rows are paid per hour or per day

A sum does not complain. Add up a column of 50,000 numbers and you get a figure with commas in the right places, whether or not every row means the same thing. Before you total a CSV, spend ten minutes looking at the numbers themselves: the smallest and largest, where the middle sits, how many are zero or negative, and how many digits they have. We did that on one public file, and found 521 rows in a yearly-salary column that are not yearly at all.

The short version: the sum of that column is 3,613,961,767.72, and 521 rows in it are hourly or daily rates that add only 72,294.72, so the total looks fine while the column is wrong. The checks below show how to see that in a minute, and which flags are errors and which are just big numbers.

The file

It is the NYC Open Data table "Citywide Payroll Data (Fiscal Year)" (resource k397-673e), the first 50,000 rows by row id. Anyone can fetch the same file:

bash
curl -o payroll.csv 'https://data.cityofnewyork.us/resource/k397-673e.csv?$limit=50000&$order=:id'

We fetched it on 2026-11-25: 10,148,400 bytes, 17 columns, fiscal years 2020 to 2025, every row from one agency (the Administration for Children's Services, because the rows come in id order). The city updates this dataset, so a later download can differ; the SHA-256 of ours starts 19b122d8d60d. The file holds names; we only look at the numbers and quote no person. No database is involved: every figure comes from reading the file.

Six columns are numbers: base_salary, regular_hours, regular_gross_paid, ot_hours, total_ot_paid and total_other_pay. All 50,000 rows are filled in each of them. The statistics below are what csvProfiler shows for a numeric column (we ran the same simple-statistics functions it uses on this file). The file is over the 5 MB guest limit, so in the browser it needs a free sign-up (50 MB); the file stays on your machine either way.

Check 1: minimum and maximum against what is possible

For every number column, write down one sentence about what a sensible minimum and maximum would be, then compare.

text
column               min          max         mean       median
base_salary          15.15        286,627     72,279.24   65,921
regular_hours        -518         2,240       1,431.79    1,820
regular_gross_paid   -20,547.52   332,518.52  58,242.03   60,157.15
ot_hours             -68          2,420       108.10      6.25
total_ot_paid        -5,178.10    239,066.51  5,211.03    268.53
total_other_pay      -56,667.13   158,522.44  3,927.57    2,244.57

Four things stand out before any maths:

A salary of 15.15. The column is called base_salary; nobody earns 15.15 a year. It is an hourly rate (the neighbouring pay_basis column says per Hour).

Negative hours. regular_hours goes down to -518. Hours worked cannot be negative; this is a correction row.

A year with 2,240 regular hours. There are 2,080 working hours in a 40-hour week over 52 weeks. 32 rows are above that, so ask what they mean (extra scheduled hours, a payout of leave) before treating them as typos.

Mean far from median. For ot_hours the mean is 108.1 and the median 6.25. Overtime is bunched at zero with a long tail, so "average overtime" would describe almost nobody. For total_ot_paid the mean is 5,211.03 and the median 268.53.

Check 2: where the middle half sits (quantiles)

The 25th and 75th percentiles show where most rows live. A cheap rule is the IQR fence: take the distance between them, and flag anything more than 1.5 times that distance outside.

text
base_salary   p25 58,782   p75 83,981   IQR 25,199
low fence  = 58,782 - 1.5 x 25,199 = 20,983.5
high fence = 83,981 + 1.5 x 25,199 = 121,779.5

rows below the low fence    521
rows above the high fence 2,547

The 521 rows below the fence are exactly the rows that are not paid per year: 370 are per Hour (salary 15.15 to 175.10) and 151 are per Day (281.52 to 701.68). Among the other 49,479 rows (per Annum) the smallest value is 29,483. The fence found the unit mix-up with no knowledge of what the column means.

The 2,547 rows above the high fence are another matter: they go up to 286,627 and look like real senior salaries. A flag is a question, not a verdict. 5.1% of rows were flagged high and none of those is obviously wrong.

There is a trap in the more familiar z-score (how many standard deviations from the mean). Here the mean is 72,279.24 and the standard deviation 26,633.79, so a 15.15 salary sits at only -2.71. No row is below -3, so the usual "more than 3 away" rule finds none of the 521 bad rows, and it flags 813 high-end rows instead. The mix-up is a cluster, not a lone point, and a cluster inflates the spread. Quantile fences cope with that better.

Check 3: zeros and negatives, counted

Count the rows at zero and below zero for every number column, and what they add up to.

text
column               negative rows   sum of negatives    sum of column
regular_hours              317             -30,267.52       71,589,351.26
regular_gross_paid         681          -1,423,578.24    2,912,101,590.11
ot_hours                    87              -1,030.12        5,405,022.07
total_ot_paid              198                -55,272.53      260,551,732.61
total_other_pay          1,071          -1,918,149.20      196,378,419.67

rows with at least one negative number: 1,628 (3.3%)

Are these sign flips, with a minus where there should be none? Look at pairs that should agree: hours and pay on the same row.

text
regular_hours negative and regular_gross_paid negative   264 rows   (a clean reversal)
regular_hours negative, pay positive                       52 rows
regular_hours positive, pay negative                       59 rows

ot_hours negative and total_ot_paid negative                81 rows
ot_hours negative, pay positive                              6 rows
ot_hours positive, pay negative                              4 rows

Most negatives line up: hours and pay are both negative, which is what a reversed payment looks like. The rows where they disagree (111 for regular pay, 10 for overtime) are the ones to open by hand. One of them has -80 regular hours and 707.16 of pay on a 36,955 salary.

What the negatives do to the total: the sum of regular_gross_paid is 2,912,101,590.11, and 2,913,525,168.35 without the negative rows, a difference of 1,423,578.24 or 0.049%. For total_other_pay the negatives are 0.98% of the column sum. In payroll those are real corrections and belong in a sum, so dropping them would be the error. A negative is bad data only if it should not exist in your process. Count it, then decide.

The zero count matters as much. regular_hours is 0 on 3,697 rows. On 1,720 of those, regular_gross_paid is above zero: pay with no hours recorded. On 1,619 both are zero, and on 358 the pay is negative. A column that is 7.4% zero drags every average you take, so decide whether zero means none or not recorded. Overtime hours are zero on 22,952 rows (45.9%), and that one is honest: no overtime.

Check 4: count the digits (magnitude buckets)

Replace each number with its number of digits and count. A unit mix-up shows as a small group with a different digit length.

text
base_salary     digits   rows
                2           357   (15.15 to 99.99)
                3           164   (100 to 701.68)
                5        43,312   (10,000 to 99,999)
                6         6,167   (100,000 to 286,627)

regular_gross_paid
  under 1: 11     1 digit: 16     2: 132     3: 973     4: 3,419
  5: 38,259       6: 4,888        zero: 1,621   negative: 681

The salary column has no four-digit values at all: a block of 5- and 6-digit numbers and 521 rows of 2 and 3 digits. A gap in the digit counts is a flag a chart would show at once, and a sum would not.

A short script for it, tested on this file with Python 3:

python
import csv, collections

rows = list(csv.DictReader(open("payroll.csv", encoding="utf-8")))

def digits(x):
    if x < 0: return "negative"
    if x == 0: return "zero"
    return str(len(str(int(x)))) if x >= 1 else "under 1"

for col in ["base_salary", "regular_gross_paid"]:
    c = collections.Counter(digits(float(r[col])) for r in rows)
    print(col, sorted(c.items()))

Check 5: compare a number with the column beside it

Two columns that should move together make the best test, because a wrong value is rarely wrong in both. We used two.

Pay against salary. For the 29,240 yearly-paid rows with the standard 1,820 regular hours, regular pay divided by base salary has a median of 0.989, and the 1st to 99th percentile run from 0.85 to 1.19. 17 rows are above 1.5 and 2 are above 2: the same 60,351 salary shows 121,661.46 and 332,518.52, a 5.5 ratio. They could be payouts of leave or back pay, and the file cannot say; they are the rows to ask about, not to delete.

Overtime pay per overtime hour. For the 23,916 rows with at least 10 overtime hours and positive pay, the implied hourly rate has a median of 42.53, and the 1st to 99th percentile run from 25.21 to 86.99. Five rows are outside any sensible range: four above 200 an hour (202.5, 202.9, 230.5 and 265.6) and one at 7.38. None of them would show in a min/max check on either column alone.

A related limit check: the most overtime on one row is 2,420 hours, on top of 1,820 regular hours. That is 4,240 hours in a year, 11.6 hours a day with no day off; 11 rows have over 2,000 overtime hours. Nothing is physically impossible (the largest sum of regular and overtime hours is 4,474, well under the 8,760 hours in a year), so this is a look, not a fix.

What the unit mix-up does to your totals

text
sum of base_salary, all 50,000 rows         3,613,961,767.72
sum, per Annum rows only (49,479)            3,613,889,473.00
the 521 per Hour and per Day rows                   72,294.72

mean salary, all rows         72,279.24
mean salary, per Annum rows   73,038.85     (1.05% higher)

the same 521 rows put on a yearly basis:
  370 per Hour x 2,080 hours      23,039,765
  151 per Day  x 260 days         15,916,657
  total                           38,956,422   (539 times the 72,294.72 that went into the sum)

The wrong total is wrong by 0.002%, which is why nobody notices. But the 521 rows really stand for nearly 39 million a year once converted, and a mean per person is 1.04% lower than it should be. An average by job title, where one title is mostly hourly staff, could be off by far more. The check costs a minute; finding the problem after a report went out costs more.

Which flags to trust

text
check                          flagged                       was it wrong?
min / max                      15.15, -518, 2,240            yes, yes, a question
IQR fence on salary            521 low, 2,547 high           521 low = unit mix-up; high = real
z-score on salary (|z| > 3)    0 low, 813 high               missed every bad row
negatives                      1,628 rows                    mostly reversals; 111+10 disagree
zero hours with pay            1,720 rows                    not recorded; decide
digit count                    521 rows with 2 or 3 digits   unit mix-up, clear gap
pay / salary ratio             17 over 1.5                   questions
overtime rate                  5 rows                        look at them

No single check catches everything, and each one is cheap. The rule we would keep: use the IQR fence or digit counts to find clusters, the sign and zero counts to find process questions, and a ratio between two related columns to find one-off errors.

A plain order to do it in

1. Open the file in csvProfiler (or compute min, max, p25, median, p75 and mean) for every number column.

2. Write one sentence per column on what is possible, and compare the minimum and maximum.

3. Compute the IQR fences from p25 and p75. Look at everything outside; a small cluster in a different range is a unit or scale problem.

4. Count negatives and zeros, and compare the sign with the related column.

5. Count digits. Look for gaps.

6. Compare one column against another it should follow, and look at the ratio's extremes.

7. Only then add things up, and say in a note which rows you included.

If you will load the file into a database after this, the five column checks cover types, empties, keys, dates and line breaks, and a messy CSV into Postgres walks through the clean and load steps. We did not load this file into a database for this article.

Profile your own CSV in the browser: min, max, mean, median and quartiles for every number column, plus empties and distinct counts. The file stays on your machine.

Open csvProfiler

Once the numbers are clean, Pilotbase is a database client for Windows, macOS and Linux, or Docker on a server: load the file, query it and look at the rows.

Get Pilotbase