Hello I am wondering if I could use something like "try-except" to avoid error warnings and put np.nan in the result array?
for example
import numpy as np
a = np.array([1,1])
b = np.array([1,0])
c = a/b
there will be a "division by zero error" I wish to neglect this error and get c as np.array([1,np.nan])
I know I could use a loop and try-except to achieve this by iterate through all elements in the array. However, is there a more elegant way to do this with out a loop?
If it has to be a loop, what would be the fastest way to do?