I have two 2d numpy lists. I want to shuffle it, but just outer side shuffle.
If i randomize order list a, I want list b to follow list a's order.
I have seen randomizing two lists and maintaining order in python but this looks not work for me.
The below code is how I'm doing now.
But it's too slow for big numpy lists.
import numpy as np
import random
a = np.array([[1,2,3], [4,5,6], [7,8,9], [10,11,12]])
b = np.array([[100,200,300,400,500], [600,700,800,900,901], [101,102,103,104,105], [501,502,503,504,505]])
r = [i for i in range(4)]
random.shuffle(r)
newa = np.empty((0, 3))
newb = np.empty((0, 5))
for rr in r:
newa = np.append(newa, [a[rr]], axis=0)
newb = np.append(newb, [b[rr]], axis=0)
print(newa)
print(newb)
Any pythonic or faster way to do this?
Thanks for answer.