I am trying this simple code to search in an array and replace the elements that are greater than 1 to 1:
import numpy as np
j = np.array([[1],[3],[1],[0],[9]])
for x in j:
if abs(x) > 1 :
j[x] = 1
But I get such errors:
IndexError: index 9 is out of bounds for axis 0 with size 5
enumerate, and use the enumerated index to change the element.