Coding Now – Best AI & Full Stack Courses in Delhi NCR | 100% Placement
Limited Offer: Get 50% OFF on AI & Full Stack Courses
📞 Call Now: +91 9667708830
Back to Machine Learning Notes
Topic #403

Missing Values

Missing values are gaps in your data — and why a value is missing matters as much as how many are missing, because it determines whether it's safe to fill the gap or whether doing so introduces bias.

Detecting Missing Values

import pandas as pd

df = pd.read_csv("survey.csv")

print(df.isnull().sum())              # missing count per column
print(df.isnull().mean() * 100)        # missing percentage per column
print(df[df["income"].isnull()])       # inspect the actual rows with gaps

Three Types of "Missing" — Why It Matters

TypeMeaningExampleSafe to Impute?
MCAR (Missing Completely At Random)Missingness is unrelated to any variableA sensor randomly drops readingsYes — imputation introduces little bias
MAR (Missing At Random)Missingness depends on other observed variablesOlder survey respondents skip the "salary" question more oftenYes, if you use those related variables to impute
MNAR (Missing Not At Random)Missingness depends on the missing value itselfHigh earners specifically decline to state salaryRisky — naive imputation systematically biases the result

Practical Use Cases

  • Deciding whether to drop a column entirely (if >50–60% missing, often not worth keeping) vs. imputing
  • Flagging missingness itself as a feature — sometimes "did the customer skip this field?" is predictive on its own

Common Mistakes

  • Filling every missing value the same way regardless of missingness type — especially dangerous for MNAR data.
  • Dropping rows with missing values without checking how many rows that removes — silently losing 30% of your dataset is rarely the right call.
  • Imputing the target variable — rows with a missing target should be dropped, never filled in.

Interview Relevance

Q: "Why does it matter whether data is MCAR, MAR or MNAR before you impute it?" Because naive imputation (like filling with the mean) assumes the missingness carries no information — true for MCAR, often false for MNAR, where the fact that a value is missing is itself informative and imputing it flattens a real signal.

Practice Question

A loan application dataset has a "monthly_income" column that's missing more often for applicants who were ultimately rejected. Is this more likely MCAR, MAR, or MNAR — and why does it matter for how you handle it?

Related ML Notes

Want to go beyond the notes?

Join CodingNow's Machine Learning course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available
💬 Talk to Advisor
1
WhatsApp

Latest from Our Blog

Insights on AI, Data Science, Full Stack & Career

View All Articles →