🌐
Codecademy
codecademy.com › docs › python › math module › math.isnan()
Python | Math Module | math.isnan() | Codecademy
September 4, 2024 - In the example below, math.isnan() returns True because the variable nan, created using float, represents a “Not a Number” (NaN) value: ... Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
🌐
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 ...
🌐
DataCamp
datacamp.com › home › tutorials › python › python nan: 4 ways to check for missing values in python
Python NaN: 4 Ways to Check for Missing Values in Python | DataCamp
February 15, 2024 - import math # Assuming my_number is a float or can be converted to one my_number = float('nan') print(math.isnan(my_number)) # Output: TruePowered by · Learn-by-Example editor, press Tab to Enter. Press Escape and then Tab or Shift+Tab to navigate out. ... Identifying and managing NaN values is a fundamental step in cleaning and preparing your data for analysis. Whether you're working with arrays, series, or data frames, understanding the tools and methods available in Python to deal with missing data is essential.
🌐
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 Twitter for latest update.
🌐
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'>
🌐
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]] ...
🌐
Tutorial Gateway
tutorialgateway.org › python-isnan
Python isnan
August 10, 2026 - import math print(math.isnan(1)) print(math.isnan(0.00)) print(math.isnan(-2)) print(math.isnan(-4.0002)) print(math.isnan(math.pi)) ... In this Mathematical function example, we are using the infinity, math.inf, not a number values as the method ...
🌐
W3Schools
w3schools.com › python › ref_math_isnan.asp
Python math.isnan() Method
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Practice Problems Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Training ... # Import math Library import math # Check whether some values are NaN or not print (math.isnan (56)) print (math.isnan (-45.34)) print (math.isnan (+45.34)) print (math.isnan (math.inf)) print (math.isnan (float("nan"))) print (math.isnan (float("inf"))) print (math.isnan (float("-inf"))) print (math.isnan (math.nan)) Try it Yourself »
🌐
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 ·
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-math-library-isnan-method
Python math library | isnan() method - GeeksforGeeks
February 20, 2023 - # Python3 code to demonstrate # the working of isnan() import math # initializing the value test_int = 4 test_neg_int = -3 test_float = 0.00 # checking isnan() values # with different numbers print (math.isnan(test_int)) print (math.isnan(t...
🌐
GeeksforGeeks
geeksforgeeks.org › python › check-for-nan-values-in-python
Check For NaN Values in Python - GeeksforGeeks
July 23, 2025 - # code import numpy as np # Example array array = np.array([1, 2, np.nan, 4, 5]) # Check for NaN values nan_check = np.isnan(array) print(nan_check)
🌐
Turing
turing.com › kb › nan-values-in-python
How to Check for NaN Values in Python?[With Examples]
The math module in Python provides the isnan() function, which can be used to check if a value is NaN. This method works only with floating-point values. Here's an example:
🌐
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 › 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
🌐
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.
🌐
Tutorialspoint
tutorialspoint.com › python › python_math_isnan_method.htm
Python math.isnan() Method
import math x = float('nan') result = math.isnan(x) print("The result is:",result) ... In this example, we are checking if the integer number "100" is NaN using the math.isnan() method −
🌐
Syntx Scenarios
syntaxscenarios.com › home › python › how to check if a value is nan in python?
How To Check if a Value Is NaN in Python? - Syntax Scenarios
November 25, 2024 - First, the math module is imported in this code. Then, a variable is created and assigned a NaN value. The variable is then passed to the isnan() function of the math module and a print statement is used to print the value returned by the function.
🌐
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.
🌐
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') ...