I have a Numpy object with random N*M elements, and I also have two numbers A and B.
Now I want to access every element in this N*M array and make a change, i.e., if the element > 0, replace this element to A (i.e., element <- A), and if this element < 0, replace this element to B (i.e., element <- B).
I know there is a naive way to implement this method, that is accessing every single element using for loop, but it is very slow.
Can we use more fancy code to implement this ?
numpy.clip.np.where