mercredi 6 mars 2019

Selecting 3 random elements from an array in python

I am trying to select three random elements from within a array. I currently have implemented:

result= np.random.uniform(np.min(dataset[:,1]), np.max(dataset[:,1]), size=3

Which returns three random floats between the min and max range. I am struggling finding a way to select random elements within an array, instead of a random float which may not exist as an element inside the array.

I have also tried:

result = random.choice(dataset[:,0])

Which only returns a single element, is it possible to return 3 with this function




Aucun commentaire:

Enregistrer un commentaire