🌐
NumPy
numpy.org › doc › stable › reference › generated › numpy.isnan.html
numpy.isnan — NumPy v2.5 Manual
Examples · Try it in your browser! >>> import numpy as np >>> np.isnan(np.nan) True >>> np.isnan(np.inf) False >>> np.isnan([np.log(-1.),1.,np.log(0)]) array([ True, False, False]) Go BackOpen In Tab ·
🌐
w3resource
w3resource.com › numpy › logic-functions › isnan.php
NumPy Logic functions: isnan() function - w3resource
May 2, 2026 - NumPy.isnan() method Example-3: >>> import numpy as np >>> np.isnan([np.log(-2.),2.,np.log(0)]) Output: array([ True, False, False]) Python - NumPy Code Editor: PREV : isinf() function NEXT : isnat() function  · Follow us on Facebook and ...
Discussions

math.nan and numpy.nan
NAN by IEEE-744 standard is not equal to any other float value, including other NAN, infinities etc. import math print(math.nan == math.nan) # False To check if a floating point value is NAN, you can use the isnan function: import math import numpy print(math.isnan(math.nan)) # True print(numpy.isnan(numpy.nan)) # True More on reddit.com
🌐 r/learnpython
2
2
January 16, 2023
How should I initialize a numpy array of NaN values?
>>> np.full(3, np.nan) But the bigger question is why would you want to? Edit: as an explanation, your example does not work because you initialized an array of ints. ints have no "NaN" value, only floats do. So your method would work if you initialized an array of floats: >>> x = np.array([0.0,0.0,0.0]) >>> x.fill(np.nan) >>> x array([ nan, nan, nan]) Or converted the ints to floats: >>> x = np.array([0,0,0], dtype=np.float) >>> x.fill(np.nan) >>> x array([ nan, nan, nan]) But the np.full() method is much better. More on reddit.com
🌐 r/learnpython
5
5
April 8, 2016
Help understanding this 'float' object is not callable error
That's not what I get, which is TypeError: 'float' object is not subscriptable on the line where you assign to r. The result of m.e**(2*x) is a number, not a list and you can't use [] with a number. y[x+h] is nonsense. It looks like you're thinking of these assignment statements as if they were equations, but they're not. (That's not an uncommon mistake, because programming often borrows concepts and notation from mathematics, but not in this case.) For example, if you wrote y = x**4, that means "take the current value of x, raise is to the fourth power, and assign the result to y." It does not mean that y is now a function that can be called to raise any x to the fourth power, as would be the case if you were in a mathematics class and wrote y(x) = x4 on the board. If you want that, you need to explicitly define y as a function (i.e. with def or a lambda.) More on reddit.com
🌐 r/learnpython
7
5
October 11, 2015
math.isnan() vs = float('nan')
That's very interesting, because what you describe is the opposite of the expected behavior. >>> float('nan') == float('nan') False >>> math.isnan(float('nan')) True Show your code, please use a code block if posting on reddit. https://www.reddit.com/r/learnpython/wiki/faq#wiki_how_do_i_format_code.3F Or paste in pastebin.com and give a link here. More on reddit.com
🌐 r/learnpython
1
2
November 24, 2022
🌐
GeeksforGeeks
geeksforgeeks.org › python › numpy-isnan-python
numpy.isnan() in Python - GeeksforGeeks
March 8, 2024 - # Python Program illustrating # numpy.isnan() method import numpy as geek # Returns True/False value for each element b = geek.arange(20).reshape(5, 4) print("\n",b) print("\nIs NaN(Not a Number): \n", geek.isnan(b)) b = [[1j], [geek.nan]] ...
🌐
NumPy
numpy.org › devdocs › reference › generated › numpy.isnan.html
numpy.isnan — NumPy v2.6.dev0 Manual
Examples · Try it in your browser! >>> import numpy as np >>> np.isnan(np.nan) True >>> np.isnan(np.inf) False >>> np.isnan([np.log(-1.),1.,np.log(0)]) array([ True, False, False]) Go BackOpen In Tab ·
🌐
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'>
🌐
Medium
medium.com › @amit25173 › numpy-isnan-in-python-63b8c185331e
numpy.isnan in Python. If you think you need to spend $2,000… | by Amit Yadav | Medium
February 9, 2025 - Here’s how: import numpy as np # Example array with NaN values arr = np.array([1, 2, np.nan, 4, np.nan, 6]) # Replace NaN values with a specific number, e.g., 0 arr_cleaned = np.where(np.isnan(arr), 0, arr) print("Array after replacing NaN ...
🌐
NumPy
numpy.org › doc › 2.2 › reference › generated › numpy.isnan.html
numpy.isnan — NumPy v2.2 Manual
Examples · >>> import numpy as np >>> np.isnan(np.nan) True >>> np.isnan(np.inf) False >>> np.isnan([np.log(-1.),1.,np.log(0)]) array([ True, False, False]) On this page
🌐
GeeksforGeeks
geeksforgeeks.org › numpy-isnan-python
numpy.isnan() in Python - GeeksforGeeks
March 8, 2024 - # Python Program illustrating # numpy.isnan() method import numpy as geek # Returns True/False value for each element b = geek.arange(20).reshape(5, 4) print("\n",b) print("\nIs NaN(Not a Number): \n", geek.isnan(b)) b = [[1j], [geek.nan]] ...
🌐
NumPy
numpy.org › doc › 2.1 › reference › generated › numpy.isnan.html
numpy.isnan — NumPy v2.1 Manual
Examples · >>> import numpy as np >>> np.isnan(np.nan) True >>> np.isnan(np.inf) False >>> np.isnan([np.log(-1.),1.,np.log(0)]) array([ True, False, False]) On this page
Find elsewhere
🌐
Note.nkmk.me
note.nkmk.me › home › python › numpy
NumPy: Replace NaN (np.nan) using np.nan_to_num() and np.isnan() | note.nkmk.me
January 23, 2024 - What is nan in Python (float('nan'), math.nan, np.nan) a_nan = np.array([0, 1, np.nan, float('nan')]) print(a_nan) # [ 0. 1. nan nan] source: numpy_nan_replace.py · Since comparing NaN with == returns False, use np.isnan() to check if the value is NaN. numpy.isnan — NumPy v1.26 Manual ·
🌐
Codegive
codegive.com › blog › numpy_check_is_nan.php
Numpy check is nan
Always use np.isnan(). Assuming NaN is equivalent to None or 0: In Python, None is a distinct object representing the absence of a value, and 0 is a number. NaN is a special floating-point value. While they all signify "missingness" in some contexts, they are handled differently. NumPy int arrays cannot contain NaN or None.
🌐
Sling Academy
slingacademy.com › article › understanding-numpy-isnan-function-4-examples
Understanding NumPy isnan() function (4 examples) - Sling Academy
The numpy.isnan() function is used to check for NaN in an array. It returns a Boolean array of the same shape as the input, indicating whether each element is NaN or not. This is particularly useful in data cleaning, preprocessing, and analysis where NaN values might indicate missing or erroneous ...
🌐
NumPy
numpy.org › doc › stable › reference › generated › numpy.isnan.html
numpy.isnan — NumPy v2.3 Manual
Examples · Try it in your browser! >>> import numpy as np >>> np.isnan(np.nan) True >>> np.isnan(np.inf) False >>> np.isnan([np.log(-1.),1.,np.log(0)]) array([ True, False, False]) Go BackOpen In Tab ·
🌐
Kodeclik
kodeclik.com › numpy-isnan
numpy.isnan() in Python
October 27, 2025 - Python’s numpy.isnan() takes an array as input and does an element-wise check for NaN values and returns the results as a boolean array highlighting the locations where an NaN was found.
🌐
pythontutorials
pythontutorials.net › blog › numpy-isnan
Mastering `numpy.isnan`: A Comprehensive Guide — pythontutorials.net
numpy.isnan is a function provided by the NumPy library that is used to test element-wise whether a given array contains NaN values. It returns a boolean array of the same shape as the input array, where each element is True if the corresponding ...
🌐
NumPy
numpy.org › doc › 1.14 › reference › generated › numpy.isnan.html
numpy.isnan — NumPy v1.14 Manual
>>> np.isnan(np.nan) True >>> np.isnan(np.inf) False >>> np.isnan([np.log(-1.),1.,np.log(0)]) array([ True, False, False])
🌐
Saturn Cloud
saturncloud.io › blog › efficiently-checking-if-arbitrary-object-is-nan-in-python-numpy-pandas
Efficiently Checking if Arbitrary Object is NaN in Python Numpy and Pandas | Saturn Cloud Blog
May 1, 2026 - For example, if you are working with NumPy arrays, use np.isnan() consistently throughout your code. import numpy as np value = np.nan if np.isnan(value): # Consistent use of NumPy's isnan() print('Value is NaN') else: print('Value is not NaN') ...
🌐
NumPy
numpy.org › doc › 2.0 › reference › generated › numpy.isnan.html
numpy.isnan — NumPy v2.0 Manual
Examples · >>> np.isnan(np.nan) True >>> np.isnan(np.inf) False >>> np.isnan([np.log(-1.),1.,np.log(0)]) array([ True, False, False]) On this page
🌐
TutorialsPoint
tutorialspoint.com › numpy › numpy_identifying_missing_values.htm
NumPy - Identifying Missing Values
In the example below, we use the np.isnan() function to create a mask that identifies NaN values specifically in the 'age' field of a structured array − · import numpy as np # Creating a structured array with NaN values dtype = [('name', ...
🌐
Bomberbot
bomberbot.com › python › mastering-numpys-isnan-the-ultimate-guide-for-python-data-scientists
Mastering NumPy's isnan(): The Ultimate Guide for Python Data Scientists - Bomberbot
This example demonstrates how numpy.isnan() can be used in conjunction with pandas and matplotlib to analyze and visualize missing data patterns in a real-world dataset. It showcases the function's utility in data preprocessing, visualization, and statistical analysis.