I have a 2d-numpy-array (28x28) and would like to set random values to all that indices which have a value lower than 50. I tried something:
myarray[myarray < 50] = random.randint(80,100)
This doesn't work correctly because all selected indices are getting the same random value. I would like to have different random values.
for y in range(28):
for x in range(28):
if myarray[y,x] < 50:
myarray[y,x] = random.randint(80,100)
The code above is solving the problem, but I think that it doesn't work efficently, because it gets very slow with big datasets.
Is there any better function?