Counting Missing Values in Pandas – Best Techniques 2026
Accurately counting missing values is the foundation of any good data cleaning process. In 2026, Pandas provides several efficient and informative ways to count missing values, from simple totals to detailed per-column and per-row breakdowns.
TL;DR — Most Useful Commands
df.isna().sum()– Count missing values per columndf.isna().sum().sum()– Total missing values in the entire DataFramedf.isna().mean() * 100– Percentage of missing values per columndf.isna().sum(axis=1)– Missing values per row
1. Basic Counting of Missing Values
import pandas as pd
df = pd.read_csv("sales_data.csv", parse_dates=["order_date"])
# Count missing values in each column
missing_count = df.isna().sum()
print("Missing values per column:")
print(missing_count.sort_values(ascending=False))
# Total number of missing values in the whole dataset
total_missing = df.isna().sum().sum()
print(f"
Total missing values in dataset: {total_missing}")
2. Percentage of Missing Values
# Percentage missing per column (very useful for reporting)
missing_pct = df.isna().mean() * 100
print("Percentage of missing values per column:")
print(missing_pct.round(2).sort_values(ascending=False))
3. Row-wise Missing Value Count
# How many missing values are in each row?
row_missing = df.isna().sum(axis=1)
print(f"Rows with at least one missing value: {(row_missing > 0).sum()}")
print("
Distribution of missing values per row:")
print(row_missing.value_counts().sort_index())
4. Best Practices in 2026
- Always start with
df.isna().sum()to see missing values per column - Use
df.isna().mean() * 100to understand the percentage of missing data - Sort the results with
.sort_values(ascending=False)to focus on the worst columns first - Check row-wise missingness with
df.isna().sum(axis=1)when rows are important - Combine counting with visualization (bar plot or heatmap) for better understanding
Conclusion
Counting missing values accurately is the first critical step in data cleaning. In 2026, the combination of df.isna().sum() for counts and df.isna().mean() * 100 for percentages gives you a clear picture of data quality. Always analyze both column-wise and row-wise missingness before deciding how to handle the missing data.
Next steps:
- Run a complete missing value count analysis on one of your current datasets using the methods above and identify which columns need attention