Reputation: 1370
I have a matrix and I want to get two different matrixes depending on a list of rows. The indexes are created randomly. I know how the get the first part:
indexes = np.random.randint(low=0, high=num_rows size=splitsize)
part1 = data[indexes, :]
How do I get the other part of the data?
Upvotes: 0
Views: 398
Reputation: 86138
Perhaps you can use numpy.sediff1d
to get index of the "other" part and that use that to index the matrix.
In [24]: num_rows = 8
In [25]: indexes = [2,3,5]
In [26]: other = np.setdiff1d(np.arange(num_rows), indexes)
In [27]: other
Out[27]: array([0, 1, 4, 6, 7])
Upvotes: 1