I am trying to shuffle each row's columns independently in a Numpy 2D array and I tried using the solution from here, but my array stays the same as before the operation. Here is my code:
perms = np.random.rand(*deltas.shape).argsort(1) #deltas is a 2d array of float values
deltas = deltas[perms, np.arange(deltas.shape[1])]
As I said deltas
stays the same as before after executing deltas = deltas[perms, np.arange(deltas.shape[1])]
. I cannot find the problem. I have a Numpy version 1.16.2
EDIT:
It seems my indexing is not correct, since it shuffles correctly if I call .argsort(0)
, but I want it to work with .argsort(1)
.