xxxxxxxxxx
import random
l = list(range(5))
print(l)
# [0, 1, 2, 3, 4]
lr = random.sample(l, len(l))
print(lr)
# [3, 2, 4, 1, 0]
print(l)
# [0, 1, 2, 3, 4]
xxxxxxxxxx
import numpy as np
# Create a numpy array
arr = np.array([1, 2, 3, 4, 5])
# Shuffle the array
np.random.shuffle(arr)
print(arr)
xxxxxxxxxx
sklearn.utils.shuffle(array, random_state, n_samples)
#The sklearn.utils.shuffle() does not change the original input but returns the input’s shuffled copy.
xxxxxxxxxx
import random
# Example array
array = [1, 2, 3, 4, 5]
# Shuffle the array in place
random.shuffle(array)
print(array) # Output: [3, 4, 1, 5, 2]
xxxxxxxxxx
import random
ary = [8, 7, 1, 67, 77, 108, 801, 800, 777, 131, 414]
new_array = random.sample(ary, len(ary) )
for items in range(100):
print(random.sample(ary, len(new_array)))