nacheck
Find every missing value in a pandas DataFrame (including the hidden ones), see where and why they are missing, and get the right fix for each column.
df.isna() only sees real NaN. Real data hides its gaps as -999, 9999, "N/A", "unknown",
"?" or a blank string, and those silently wreck your averages and models. nacheck finds them all,
tells you where they are, why they are missing, and what to do about each column, then fixes it
in one line.
pip install nacheck
Quick start
import nacheck
df = nacheck.make_messy() # a realistic messy survey (or use your own DataFrame)
report = nacheck.scan(df, target="passed")
print(report)
Real output:
nacheck: 1,000 rows x 11 columns · 1,526 missing values (14%), of which 278 were hidden
[HIDDEN] gender: 'unknown' x37, ' ' x25
[HIDDEN] income: -999 x61 -> -999 pulls the mean from 35.6 to -32.3
[HIDDEN] distance_km: 9999 x40 -> 9999 pulls the mean from 2.82 to 405.1
[HIDDEN] exam_score: 'N/A' x32, 'absent' x41 (numbers stored as text)
[HIDDEN] email: 'N/A' x42
age: 37 missing (3.7%) in rows 38, 41, 71, 161, 205, ...
fix: fill with the mean (roughly symmetric and the gaps look random)
gender: 68 missing (6.8%) in rows 13, 17, 38, 51, 55, ...
fix: fill with 'Missing' (too many gaps to give them all the most common value)
income: 132 missing (13%) in rows 3, 11, 13, 21, 36, ...
why: missing 40% of the time when region = Mountain vs 6.7% otherwise
note: rows missing income have a lower passed (0.31 vs 0.45): the gap itself is informative
fix: fill with the median by 'region' + add 'income_was_missing' (region explains 35% of its variation, so one overall value would be wrong; the flag keeps the information that it was missing)
distance_km: 46 missing (4.6%) in rows 33, 38, 43, 48, 53, ...
fix: fill with the median by 'region' (region explains 25% of its variation, so one overall value would be wrong)
exam_score: 79 missing (7.9%) in rows 3, 6, 26, 36, 38, ...
fix: fill with the median by 'region' (region explains 16% of its variation, so one overall value would be wrong)
phone: 125 missing (12%) in rows 2, 4, 8, 16, 30, ...
fix: fill with 'Missing' (free text or unique values (names, phones, emails) cannot be guessed, so mark them)
email: 125 missing (12%) in rows 2, 4, 8, 16, 30, ...
fix: fill with 'Missing' (free text or unique values (names, phones, emails) cannot be guessed, so mark them)
comments: 906 missing (91%) in rows 0, 1, 2, 3, 4, ...
fix: drop the column (91% missing is too much to fill reliably)
passed: 8 missing (0.8%) in rows 205, 348, 455, 525, 733, ...
fix: drop the rows (never fill the target you want to predict)
[TOGETHER] phone and email are missing in the same rows (100% overlap): probably one skipped section or failed source
[ROWS] 7 rows are mostly empty (>= 50% missing): 38, 205, 226, 501, 545, ... -> drop them
Apply all fixes: clean = report.fix()
Then fix everything in one line:
clean = report.fix()
print("\n".join(report.fix_log))
revealed 278 hidden missing values as NaN
dropped column(s): comments
dropped 7 mostly-empty row(s)
dropped 7 row(s) missing passed
age: filled 30 with the mean 16.051
gender: filled 61 with the value 'Missing'
income: filled 125 with the median by region (Hill 31, Mountain 18, Terai 32.4, Valley 51.6)
distance_km: filled 39 with the median by region (Hill 1.8, Mountain 4.4, Terai 1.7, Valley 1.85)
exam_score: filled 73 with the median by region (Hill 53.5, Mountain 45, Terai 54, Valley 61)
phone: filled 118 with the value 'Missing'
email: filled 118 with the value 'Missing'
added income_was_missing (125 flagged)
result: 986 rows x 11 columns, 0 missing values left
What it does
| Finds hidden missing values | -999, 9999, -1 (only in non-negative columns), "N/A", "unknown", "?", "#N/A", blank strings and 30+ more, plus numbers stored as text because of an "N/A". Numeric codes only count when they sit far outside the real data, so a genuine score of 99 is never flagged. |
| Shows the damage | "-999 pulls the mean from 35.6 to -32.3" |
| Where | count, percentage and the rows for every column; report.where("income") gives all of them |
| Why | whether the gaps look random or depend on another column ("missing 40% of the time when region = Mountain vs 6.7% otherwise"), and whether they predict your target |
| What to do | one recommendation per column, with the reason: drop the column, drop the rows, mean, median, most common value, a "Missing" category, median by group, interpolate or carry forward (time series), plus a _was_missing flag when the gap itself carries information |
| Patterns | columns that go missing together (a skipped survey section) and rows that are mostly empty |
| Fix | report.fix() applies everything and logs each change; override any column with report.fix({"age": "median"}) |
| No leakage | fill values are learned once: report.fixer.transform(test_df) applies the training medians to new data |
report.plot() draws the map above: dark cells are real NaN, orange cells are hidden codes.
How it chooses a fix
| Situation | Recommendation |
|---|---|
it is your target |
drop those rows (never fill what you want to predict) |
| more than 60% missing | drop the column |
time-series data (time_col= or a DatetimeIndex) |
interpolate numbers, carry other values forward |
| numeric, under 1% missing and random | drop the rows |
| numeric, another column explains at least 10% of its variation | median by that group |
| numeric, skewed | median |
| numeric, symmetric | mean |
| categorical, under 5% missing and random | most common value |
| categorical, more gaps or gaps that mean something | a "Missing" category |
| names, phones, emails, free text | a "Missing" marker |
| missingness depends on other columns or predicts the target | also add <column>_was_missing |
"Depends on another column" uses a chi-square test (categories) or Welch's test (numbers) with Bonferroni correction, so random gaps are not mistaken for patterns: on 20 datasets with purely random gaps it raised no false alarms, and this is checked in the test suite.
More
report.to_frame() # one row per column: where, pattern, fix, reason
report.plan # the recommended plan as a dict, edit and pass to fix()
nacheck.reveal(df) # just turn hidden codes into real NaN
df.nacheck.scan(target="y") # DataFrame accessor
nacheck.scan(df, text_sentinels=["n.k."], numeric_sentinels=[-7], ignore=["None"])
# train / test without leakage
report = nacheck.scan(train, target="y")
train_clean = report.fix()
test_clean = report.fixer.transform(test, drop_rows=False)
Also by the author
- gapnet: an interpretable neural network that finds how effects differ between groups
- simpsonscan: find Simpson's paradoxes in your data
- chartaudit: catch misleading charts
- pandas-mergeguard: predict and audit pandas merges
MIT licensed. Contributions welcome.
Metadata
Release files for nacheck 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nacheck-0.1.0.tar.gz | 31.6 kB | With provenance | Details for nacheck-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nacheck-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for nacheck-0.1.0-py3-none-any.whl |
Total release size: 54.2 kB
Release files / nacheck-0.1.0.tar.gz
| Download URL | nacheck-0.1.0.tar.gz |
|---|---|
| Size | 31.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2d7690c17c426f968735cc1611bc38b73e4be5724ebec3bc6b051108e8e03bf2
|
|
BLAKE2b-256 checksum How to use checksums |
53fcb4e84370a10bc72370c4de698d0f4f71fc3bc01a31d062ea9b616928b435
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 2, 2026.
Transparency logRelease files / nacheck-0.1.0-py3-none-any.whl
| Download URL | nacheck-0.1.0-py3-none-any.whl |
|---|---|
| Size | 22.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
35ac2b55194b2fecc3f8199872314f074e0a5dc0d3d6258b2b00aaa33af9a90c
|
|
BLAKE2b-256 checksum How to use checksums |
c0d91f68c72a2b61026fa263c33eba3509df597ab2dcbe49a568d8008afc379c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 2, 2026.
Transparency logSecurity for nacheck 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for nacheck-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 2, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.