I have a table like this;
table = np.array([[ 67, 15],
[ 90, 15],
[ 92, 15],
[ 67, 25],
[138, 25],
[138, 35],
[ 62, 15],
[ 70, 25],
[ 71, 25],
[124, 35]])
I want to select predetermined number of rows (target) which include unique values (never shown before) if it is possible . If it is not, selecting with same order by following the same logic.
I.e., if I want to select;
2 rows: [67,15], [138,25]
3 rows: [67,15], [138,25], [124,35]
4 rows: [67,15], [138,25], [124,35] , [90,15]
5 rows: [67,15], [138,25], [124,35] , [90,15] , [67,25]
and so on.
Here is my trial;
space = []
id_space = [0]
space.append(table[0,:])
target = 3
row = 1
for i in range(1,len(table)):
if not (any(np.isin(table[i,:],np.hstack(space)))):
space.append(table[i,:])
id_space.extend([i])
row = row + 1
if (row==target):
break
table[id_space]
It works up until target = 3, but does not for the rest. By the way, matrix named table is really huge in reality. Maybe some faster alternatives are also available.
Thanks in advance!