jwilner's response is spot on. I was exploring to see if there's a faster option, since in my experience, summing flat arrays is (strangely) faster than counting. This code seems faster:

df.isnull().values.any()

import numpy as np
import pandas as pd
import perfplot


def setup(n):
    df = pd.DataFrame(np.random.randn(n))
    df[df > 0.9] = np.nan
    return df


def isnull_any(df):
    return df.isnull().any()


def isnull_values_sum(df):
    return df.isnull().values.sum() > 0


def isnull_sum(df):
    return df.isnull().sum() > 0


def isnull_values_any(df):
    return df.isnull().values.any()


perfplot.save(
    "out.png",
    setup=setup,
    kernels=[isnull_any, isnull_values_sum, isnull_sum, isnull_values_any],
    n_range=[2 ** k for k in range(25)],
)

df.isnull().sum().sum() is a bit slower, but of course, has additional information -- the number of NaNs.

Answer from S Anand on Stack Overflow
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.isnull.html
pandas.isnull — pandas 3.0.1 documentation
>>> df = pd.DataFrame([["ant", "bee", "cat"], ["dog", None, "fly"]]) >>> df 0 1 2 0 ant bee cat 1 dog NaN fly >>> pd.isna(df) 0 1 2 0 False False False 1 False True False
Top answer
1 of 16
892

jwilner's response is spot on. I was exploring to see if there's a faster option, since in my experience, summing flat arrays is (strangely) faster than counting. This code seems faster:

df.isnull().values.any()

import numpy as np
import pandas as pd
import perfplot


def setup(n):
    df = pd.DataFrame(np.random.randn(n))
    df[df > 0.9] = np.nan
    return df


def isnull_any(df):
    return df.isnull().any()


def isnull_values_sum(df):
    return df.isnull().values.sum() > 0


def isnull_sum(df):
    return df.isnull().sum() > 0


def isnull_values_any(df):
    return df.isnull().values.any()


perfplot.save(
    "out.png",
    setup=setup,
    kernels=[isnull_any, isnull_values_sum, isnull_sum, isnull_values_any],
    n_range=[2 ** k for k in range(25)],
)

df.isnull().sum().sum() is a bit slower, but of course, has additional information -- the number of NaNs.

2 of 16
245

You have a couple of options.

import pandas as pd
import numpy as np

df = pd.DataFrame(np.random.randn(10,6))
# Make a few areas have NaN values
df.iloc[1:3,1] = np.nan
df.iloc[5,3] = np.nan
df.iloc[7:9,5] = np.nan

Now the data frame looks something like this:

          0         1         2         3         4         5
0  0.520113  0.884000  1.260966 -0.236597  0.312972 -0.196281
1 -0.837552       NaN  0.143017  0.862355  0.346550  0.842952
2 -0.452595       NaN -0.420790  0.456215  1.203459  0.527425
3  0.317503 -0.917042  1.780938 -1.584102  0.432745  0.389797
4 -0.722852  1.704820 -0.113821 -1.466458  0.083002  0.011722
5 -0.622851 -0.251935 -1.498837       NaN  1.098323  0.273814
6  0.329585  0.075312 -0.690209 -3.807924  0.489317 -0.841368
7 -1.123433 -1.187496  1.868894 -2.046456 -0.949718       NaN
8  1.133880 -0.110447  0.050385 -1.158387  0.188222       NaN
9 -0.513741  1.196259  0.704537  0.982395 -0.585040 -1.693810
  • Option 1: df.isnull().any().any() - This returns a boolean value

You know of the isnull() which would return a dataframe like this:

       0      1      2      3      4      5
0  False  False  False  False  False  False
1  False   True  False  False  False  False
2  False   True  False  False  False  False
3  False  False  False  False  False  False
4  False  False  False  False  False  False
5  False  False  False   True  False  False
6  False  False  False  False  False  False
7  False  False  False  False  False   True
8  False  False  False  False  False   True
9  False  False  False  False  False  False

If you make it df.isnull().any(), you can find just the columns that have NaN values:

0    False
1     True
2    False
3     True
4    False
5     True
dtype: bool

One more .any() will tell you if any of the above are True

> df.isnull().any().any()
True
  • Option 2: df.isnull().sum().sum() - This returns an integer of the total number of NaN values:

This operates the same way as the .any().any() does, by first giving a summation of the number of NaN values in a column, then the summation of those values:

df.isnull().sum()
0    0
1    2
2    0
3    1
4    0
5    2
dtype: int64

Finally, to get the total number of NaN values in the DataFrame:

df.isnull().sum().sum()
5
🌐
W3Schools
w3schools.com › python › pandas › ref_df_isnull.asp
Pandas DataFrame isnull() Method
The isnull() method returns a DataFrame object where all the values are replaced with a Boolean value True for NULL values, and otherwise False. ... This method takes no parameters.
🌐
Saturn Cloud
saturncloud.io › blog › python-pandas-selecting-rows-whose-column-value-is-null-none-nan
Python Pandas Selecting Rows Whose Column Value is Null None Nan | Saturn Cloud Blog
October 26, 2023 - Here, we use the loc method to select rows where any of the columns have null values. We use the isnull() method to create a boolean mask for each column and use the | operator to combine them.
🌐
Vultr Docs
docs.vultr.com › python › third-party › pandas › DataFrame › notnull
Python Pandas DataFrame notnull() - Check Non-Null Values | Vultr Docs
December 30, 2024 - Applying notnull() to the 'Age' column of the DataFrame returns a Series indicating which rows have a non-null value for age. This can help in filtering or analyzing age-specific data while ignoring missing or corrupt entries.
🌐
Saturn Cloud
saturncloud.io › blog › how-to-check-if-a-particular-cell-in-pandas-dataframe-is-null
How to Check if a Particular Cell in Pandas DataFrame is Null | Saturn Cloud Blog
October 27, 2023 - NaN is a special floating-point value that represents missing or undefined data. None is a Python object that represents missing or undefined data of any data type. To check for null values in a pandas DataFrame, we can use the isnull() method.
🌐
Atlassian
atlassian.com › data › notebook › how-to-check-if-any-value-is-nan-in-a-pandas-dataframe
How to check if any value is NaN in a pandas DataFrame
While the chain of .isnull().values.any() will work for a DataFrame object to indicate if any value is missing, in some cases it may be useful to also count the number of missing values across the entire DataFrame.
🌐
GeeksforGeeks
geeksforgeeks.org › python-pandas-isnull-and-notnull
Pandas isnull() and notnull() Method - GeeksforGeeks
May 30, 2025 - Pandas dataframe.notnull() function detects existing/ non-missing values in the dataframe. The function returns a boolean object having the same size as that of the object on which it is applied, indicating whether each individual value is a ...
Find elsewhere
🌐
YouTube
youtube.com › watch
How to Check if a Dataframe Column Has Null Values | 2 Ways in Python - YouTube
Pandas and Python are some of the most popular tools in data analytics today. In today’s video, we will talk about how you can check if a column is null. The...
Published   July 18, 2023
🌐
TutorialsPoint
tutorialspoint.com › python-pandas-check-for-null-values-using-notnull
Python Pandas – Check for Null values using notnull()
For Not-Null values, True will get displayed. ... import pandas as pd # reading csv file dataFrame = pd.read_csv("C:\Users\amit_\Desktop\CarRecords.csv") print("DataFrame...\n",dataFrame) # count the rows and columns in a DataFrame print("\nNumber of rows and column in our DataFrame = ",dataFrame.shape) res = dataFrame.notnull() print("\nDataFrame displaying False for Null (NaN) value = \n",res) dataFrame = dataFrame.dropna() print("\nDataFrame after removing null values...\n",dataFrame) print("\n(Updated) Number of rows and column in our DataFrame = ",dataFrame.shape)
🌐
DZone
dzone.com › articles › pandas-find-rows-where-columnfield-is-null
Pandas: Find Rows Where Column/Field Is Null
July 10, 2017 - The the code you need to count null columns and see examples where a single column is null and all columns are null.
🌐
Miami University
miamioh.edu › centers-institutes › center-for-analytics-data-science › students › coding-tutorials › python › data-cleaning.html
Data Cleaning | Python | CADS | Miami University
Next, we would like to check if there are any missing values. To check this, we can use the function dataframe.isnull() in pandas. It will return True for missing components and False for non-missing cells.
🌐
Saturn Cloud
saturncloud.io › blog › how-to-count-nan-and-null-values-in-a-pandas-dataframe
How to Count NaN and Null Values in a Pandas DataFrame | Saturn Cloud Blog
October 27, 2023 - In this article, we’ve explained how to count NaN and null values in a Pandas DataFrame using Python. We’ve shown how to use the isna() and isnull() methods to create Boolean masks that identify missing values and the sum() method to count ...
🌐
Imarticus Learning
imarticus.org › home › checking null values with pandas
Checking Null Values with Pandas - Finance, Tech & Analytics Career Resources | Imarticus Blog
The first step is identifying null values in your dataset. Pandas offers multiple methods to detect missing values. The isnull() method highlights missing data. Returns a DataFrame: Displays True for null values.
Published   December 31, 2024
🌐
GeeksforGeeks
geeksforgeeks.org › data analysis › working-with-missing-data-in-pandas
Working with Missing Data in Pandas - GeeksforGeeks
isnull() returns a DataFrame of Boolean value where True represents missing data (NaN).
Published   November 11, 2025
🌐
Spark Code Hub
sparkcodehub.com › pyspark › dataframe › check-null-values-dataframe
How to Check for Null Values in a PySpark DataFrame: The Ultimate Guide
Scanning large DataFrames for nulls can be resource-intensive, especially with grouping or filtering operations that involve shuffling. Optimizing performance ensures efficient null detection, critical for scaling ETL pipelines to handle big data. # Optimized grouped null check optimized_df = df.select("name", "salary", "department").filter(col("department").isNotNull()).repartition("department") null_counts_df = optimized_df.groupBy("department").agg( sum_agg(col("name").isNull().cast("integer")).alias("name_nulls"), sum_agg(col("salary").isNull().cast("integer")).alias("salary_nulls") ) null_counts_df.show(truncate=False)
🌐
Note.nkmk.me
note.nkmk.me › home › python › pandas
pandas: Detect and count NaN (missing values) with isnull(), isna() | note.nkmk.me
August 2, 2023 - This article describes how to check if pandas.DataFrame and pandas.Series contain NaN and count the number of NaN. You can use the isnull() and isna() methods. It should be noted, however, that the is ...
🌐
TutorialsPoint
tutorialspoint.com › how-to-display-notnull-rows-and-columns-in-a-python-dataframe
How to display notnull rows and columns in a Python dataframe?
import pandas as pd # Create a sample dataframe data = {'Name': ['Alice', 'Bob', 'Charlie', 'David', 'Eva'], 'Age': [25, 30, None, 20, 28], 'Gender': ['F', 'M', 'M', 'M', None], 'City': ['New York', 'San Francisco', 'Los Angeles', 'Boston', None]} df = pd.DataFrame(data) # Filter for rows and columns with non-null values df = df[df.notnull().all(axis=1)] # Display the resulting dataframe print(df) Name Age Gender City 0 Alice 25.0 F New York 1 Bob 30.0 M San Francisco 3 David 20.0 M Boston · We learned how to use different methods to display the not null values in a Python dataframe.