I need to find all the elements in an array that are >0 and then replace each one with a random number between 0 and 5 in Python 3.
I have made an array (called L) of 20 elements that each equal 0 or 1, but am struggling to replace elements individually.
I do not want
speed = np.random.randint(0,5)
L[L > 0] = speed
as this changed all the elements >0 to the same random number.
Any ideas?
Aucun commentaire:
Enregistrer un commentaire