..
a=['aaaaa','bbbb','cccc','dddd']
b=[1, 2, 3, 4]
from sklearn.utils import shuffle
list_1, list_2 = shuffle(a, b)
print(list_1, list_2)
#['cccc', 'aaaaa', 'dddd', 'bbbb'] [3, 1, 4, 2]
method #2
...
list1_shuf = []
list2_shuf = []
index_shuf = list(range(len(a)))
shuffle(index_shuf)
for i in index_shuf:
list1_shuf.append(a[i])
list2_shuf.append(b[i])
print(list1_shuf)
print(list2_shuf)
#['cccc', 'aaaaa', 'bbbb', 'dddd']
#[3, 1, 2, 4]
No comments:
Post a Comment