how to get the index of numpy.random.choice? - python

前端 未结 8 1387
粉色の甜心
粉色の甜心 2021-02-02 12:31

Is it possible to modify the numpy.random.choice function in order to make it return the index of the chosen element? Basically, I want to create a list and select elements ran

8条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-02 12:51

    Instead of using choice, you can also simply random.shuffle your array, i.e.

    random.shuffle(a)  # will shuffle a in-place
    

提交回复
热议问题