Let’s see how to shuffle an array in Numpy Python library.
Shuffling an array
With Numpy you can easily shuffle an array. Just use Numpy random shuffle method. This will shuffle your array.
import numpy as np my_list = [1, 2, 5, 7, 9, 13] print(f"My list is: \n{my_list}") my_array = np.array(my_list) np.random.shuffle(my_array) print(f"My random shuffle array is: \n{my_array}")
As you can see the order of values has been changed.