Test element-wise for NaN of a given array using NumPy.

In this python numpy program, we will test element-wise for NaN of a given array using NumPy.

Steps to solve the program
  1. Import the numpy library as np.
  2. Create an array using np.array().
  3. test element-wise for NaN of a given array using np.isnan().
  4. It will return True if an element is NaN (i.e. not a number).
  5. Print the output.
				
					import numpy as np
x = np.array([2,4,np.nan,7])

print(np.isnan(x))
				
			

Output :

				
					[False False  True False]
				
			

test a given array element-wise is finite or not.

test element-wise for complex numbers of a given array.

Leave a Comment