I am using random.shuffle to mix a 2D numpy array. I encountered the following problem:
import numpy as np from random import shuffle as sf b = np.array([1,2,3,4,5]) print b
The result shows that when shuffling the 1D array, everything is correct. But when you move the 2D array, the result becomes strange.
Why is the third row of the original array selected and the first row duplicated twice?
I know there may be solutions to solve this problem, for example, first shuffle the 1D array indicating the row identifiers, and then extract the 2D array in the order of the shuffled identifiers. But I want to clearly indicate what happens to the implementation of random.shuffle , or what is wrong with my code.
source share