I get a little problem with a simple idea. I have an array of data and I would like to replace each value if the value is greater than X.
To solve that, I wrote a little script as example which give the same idea :
import numpy as np
# Array creation
array = np.array([0.5, 0.6, 0.9825])
# If value > 0.7 replace by 0.
new_array = array[array > 0.7] == 0
>>> [0.5, 0.6, 0] # 0.9825 is replaced by 0 because > 0.7
I wonder why this solution is not provided in the link @DonkeyKong provided:
np.where(arr>0.7, 0, arr) #Out: array([ 0.5, 0.6, 0. ])