I want to create a method that will receive a numpy vector of size 1xN which contain several values among them several NaN too and will randomly replace a non-nan index with NaN. I want the return the result and also the index of the replaced element.
def replace_index(array):
index = np.random.randint(array.shape[1], size=1)
array[index] = NaN
return array, index
How can i check if the calculated index is not already a nan?