I need to create a N x M numpy array of randomly shuffled numbers 0 to N. That is to say that each row of the matrix has exactly one of each numbers 0 to N in a random order with no repeating elements and every number is represented.
The best I've been able to come up with so far is (for N = 10 and M = 5)
import random
import numpy as np
a = np.array([random.sample(range(10), 10) for x in range(5)])
which gives me
[[5 9 1 3 8 2 6 4 0 7]
[4 8 5 2 9 3 7 6 0 1]
[8 4 6 7 9 2 0 5 1 3]
[3 5 4 9 2 0 6 7 1 8]
[6 0 4 7 3 2 1 8 5 9]]
My current solution does work, but I'd like to only have one random library if possible (I'm using numpy elsewhere so a numpy only solution would be ideal). I'm assuming numpy has an easier way to do this, but I'm currently missing it.