How to create 2d array with numpy random.choice for every rows?

后端 未结 4 1857
我寻月下人不归
我寻月下人不归 2020-11-30 15:30

I\'m trying to create a 2d array (which is a six column and lots of rows) with numpy random choice with unique values between 1 and 50 for every row not all of the array

4条回答
  •  天涯浪人
    2020-11-30 16:12

    You can create each row by itself and then stack them.

    np.stack([np.random.choice(np.arange(1,50),size=6,replace=False) for i in range(100)])
    

提交回复
热议问题