numpy random shuffle by row independently

后端 未结 5 889
悲哀的现实
悲哀的现实 2020-12-17 03:14

I have the following array:

 a= array([[  1,  2, 3],
           [  1,  2, 3],
           [  1,  2, 3])

I understand that np.random,sh

5条回答
  •  隐瞒了意图╮
    2020-12-17 03:32

    Good answer above. But I will throw in a quick and dirty way:

    a = np.array([[1,2,3], [1,2,3], [1,2,3]])
    ignore_list_outpput = [np.random.shuffle(x) for x in a]
    Then, a can be something like this
    array([[2, 1, 3],
           [4, 6, 5],
           [9, 7, 8]])
    

    Not very elegant but you can get this job done with just one short line.

提交回复
热议问题