Q:

Write a NumPy program to test element-wise for NaN of a given array

0

Write a NumPy program to test element-wise for NaN of a given array

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import numpy as np
a = np.array([1, 0, np.nan, np.inf])
print("Original array")
print(a)
print("Test element-wise for NaN:")
print(np.isnan(a))

Sample Output:

Original array
[  1.   0.  nan  inf]
Test element-wise for NaN:
[False False  True False]

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now