Ray's solution is good. However, on my machine it is about 2.5x faster to use numpy.sum in place of numpy.min:

In [13]: %timeit np.isnan(np.min(x))
1000 loops, best of 3: 244 us per loop

In [14]: %timeit np.isnan(np.sum(x))
10000 loops, best of 3: 97.3 us per loop

Unlike min, sum doesn't require branching, which on modern hardware tends to be pretty expensive. This is probably the reason why sum is faster.

edit The above test was performed with a single NaN right in the middle of the array.

It is interesting to note that min is slower in the presence of NaNs than in their absence. It also seems to get slower as NaNs get closer to the start of the array. On the other hand, sum's throughput seems constant regardless of whether there are NaNs and where they're located:

In [40]: x = np.random.rand(100000)

In [41]: %timeit np.isnan(np.min(x))
10000 loops, best of 3: 153 us per loop

In [42]: %timeit np.isnan(np.sum(x))
10000 loops, best of 3: 95.9 us per loop

In [43]: x[50000] = np.nan

In [44]: %timeit np.isnan(np.min(x))
1000 loops, best of 3: 239 us per loop

In [45]: %timeit np.isnan(np.sum(x))
10000 loops, best of 3: 95.8 us per loop

In [46]: x[0] = np.nan

In [47]: %timeit np.isnan(np.min(x))
1000 loops, best of 3: 326 us per loop

In [48]: %timeit np.isnan(np.sum(x))
10000 loops, best of 3: 95.9 us per loop
Answer from NPE on Stack Overflow
🌐
NumPy
numpy.org › doc › 2.3 › reference › generated › numpy.isnan.html
numpy.isnan — NumPy v2.3 Manual
numpy.isnan(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature]) = <ufunc 'isnan'>#
🌐
GeeksforGeeks
geeksforgeeks.org › python › numpy-isnan-python
numpy.isnan() in Python - GeeksforGeeks
March 8, 2024 - The numpy.isnan() function tests element-wise whether it is NaN or not and returns the result as a boolean array.
🌐
NumPy
numpy.org › doc › 1.13 › reference › generated › numpy.isnan.html
numpy.isnan — NumPy v1.13 Manual
numpy.isnan(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj]) = <ufunc 'isnan'>¶ · Test element-wise for NaN and return result as a boolean array. See also · isinf, isneginf, isposinf, isfinite, isnat ·
🌐
Educative
educative.io › answers › what-is-numpyisnan-in-python
What is numpy.isnan() in Python?
numpy.isnan(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj]) = <ufunc 'isnan'>
Find elsewhere
🌐
SciPy
docs.scipy.org › doc › numpy-1.10.1 › reference › generated › numpy.isnan.html
numpy.isnan — NumPy v1.10 Manual
numpy.isnan(x[, out]) = <ufunc 'isnan'>¶ · Test element-wise for NaN and return result as a boolean array. See also · isinf, isneginf, isposinf, isfinite · Notes · Numpy uses the IEEE Standard for Binary Floating-Point for Arithmetic (IEEE 754). This means that Not a Number is not equivalent ...
🌐
NumPy
numpy.org › devdocs › reference › generated › numpy.isnan.html
numpy.isnan — NumPy v2.6.dev0 Manual
numpy.isnan(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature]) = <ufunc 'isnan'>#
🌐
NumPy
numpy.org › doc › stable › reference › generated › numpy.isnan.html
numpy.isnan — NumPy v2.5 Manual
numpy.isnan(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature]) = <ufunc 'isnan'>#
🌐
NumPy
numpy.org › doc › 2.1 › reference › generated › numpy.isnan.html
numpy.isnan — NumPy v2.1 Manual
numpy.isnan(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature]) = <ufunc 'isnan'>#
🌐
MindSpore
mindspore.cn › mindspore.numpy.isnan
mindspore.numpy.isnan | MindSpore 1.9 documentation | MindSpore
mindspore.numpy.isnan · View page source · mindspore.numpy.isnan(x, dtype=None)[source] · Tests element-wise for NaN and return result as a boolean array. Note · Numpy arguments out, where, casting, order, subok, signature, and extobj are not supported.
🌐
IncludeHelp
includehelp.com › python › isnotnan-functionality-in-numpy-can-this-be-more-pythonic.aspx
Python - 'isnotnan' functionality in numpy, can this be more pythonic?
October 9, 2023 - To check if a value is not a nan value, we will use isnan() method along with tilde(~) operator. The tilde sign (~) in pandas is used when we work with Boolean values. In programming, we sometimes use some specific values that only have two values, either True or False.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-math-library-isnan-method
Python math library | isnan() method - GeeksforGeeks
February 20, 2023 - One such function is isnan(). This method is used to check whether a given parameter is a valid number or not. Syntax : math.isnan(x) Parameters : x [Required] : It is any valid python data type or any number.
🌐
NumPy
numpy.org › doc › 2.2 › reference › generated › numpy.isnat.html
numpy.isnat — NumPy v2.2 Manual
numpy.isnat(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature]) = <ufunc 'isnat'>#
🌐
NumPy
numpy.org › doc › stable › search.html
Search - NumPy v2.5 Manual
Created using Sphinx 7.2.6 · Built with the PyData Sphinx Theme 0.17.1