Shuffle an array with python, randomize array item order with python
Shuffle an array with python, randomize array item order with python
import random
random.shuffle(array)
import random
random.shuffle(array)
Shuffle an array with python, randomize array item order with python
Alternative way to do this using sklearn
from sklearn.utils import shuffle
X=[1,2,3]
y = [one, two, three]
X, y = shuffle(X, y, random_state=0)
print(X)
print(y)
Output:
[2, 1, 3]
[two, one, three]
Advantage: You can random multiple arrays simultaneously without disrupting the mapping. And random_state can control the shuffling for reproducible behavior.