Better way to shuffle two related lists

后端 未结 7 2225
星月不相逢
星月不相逢 2020-12-13 09:24

Is there better ways to randomly shuffle two related lists without breaking their correspondence in the other list? I\'ve found related questions in numpy.array

7条回答
  •  被撕碎了的回忆
    2020-12-13 10:14

    If you are willing to install a few more packages:

    Req: NumPy (>= 1.6.1), SciPy (>= 0.9).

    pip install -U scikit-learn

    from sklearn.utils import shuffle
    list_1, list_2 = shuffle(list_1, list_2)
    

提交回复
热议问题