Real-world datasets are almost never 100% complete. In Pandas, missing data is represented as:
np.nan (Not a Number, a special IEEE floating-point value)pd.NA (Pandas' modern experimental nullable missing indicator)None (Standard Python null object, automatically cast to NaN in numeric columns).isna() vs .isnull()In Pandas, .isna() and .isnull() are 100% identical aliases. .isna() is preferred because it matches the modern scientific terminology (is NA).
Output (Boolean Matrix):
To compute the exact number and percentage of nulls in each column:
Output:
df[df['Salary'].isna()]: Find all rows where Salary is missing.df[df['Name'].notna()]: Keep only rows where Name is present.df.isna() and df.isnull()?df.isna(), returning True for valid non-null entries?np.nan == np.nan not be used to check for missing values?Continue learning with hands-on practice, examples, and exercises in the upcoming topic.
| Previous Lesson | Next Lesson |
|---|---|
| Setting, Resetting & Managing Indices | Dropping & Filling Missing Values (dropna, fillna) |
Test your understanding of this lesson with 5 questions. Each question has one correct answer.
Combine 15 complete courses, 150 chapters, 541 topics, live SQL/Power BI/Tableau dashboards, and Scikit-Learn capstones at MSK Institute Shikohabad or Live Online.