Q.How can you check whether a given DataFrame has any missing value or not?
You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.
Start your 14-day free trial to unlock the full solution →Use the .isna() method (or .isnull()) on the DataFrame, then chain .any() to check column-wise or .any().any() for a single True/False answer.
The core idea is that Pandas represents missing data as NaN (Not a Number) for numeric columns and None or NaN for object columns. The library provides two identical methods — .isna() and .isnull() — that return a Boolean DataFrame of the same shape, where True marks a missing cell.
The simplest check is df.isna().any().any(). Let's break that down:
df.isna()gives you a DataFrame ofTrue/False—Truewhere the original had a missing value..any()(first one) reduces each column to a single Boolean:Trueif that column has any missing value. You now have a Series..any()(second one) reduces that Series to a single Boolean:Trueif any column had a missing value.
If you want to know which columns have missing data, stop after the first .any():
df.isna().any()
That returns a Series with column names as index and True/False values.
.isna() and .isnull() are exact synonyms — use whichever reads better in your code. .isna() is slightly more common in modern Pandas.
A common pitfall: df.isna() alone is not enough — it returns a huge table of Booleans, not a single answer. You must chain .any() (or .sum()) to get a useful summary. …
Unlock everything free for 14 days
- Full step-by-step solutions
- Concept-first explanations
- Methods, shortcuts & mistakes
- PYQ mapping + timed mock tests
Full access for 14 days. No credit card required.