Hello, @GA316. There are two ways to do this, depending on whether you want to do it manually or automatically.
To remove rows manually, you just need to use the delete_rows
method: Suppose you have a matrix A
such that its 3rd, 5th and 6th rows are exactly the same as the first row, so they should be removed. Just execute:
A.delete_rows([3, 5, 6])
If you want to do it automatically, the following piece of code can help you:
def remove_repeated_rows(A):
nr = A.nrows()# number of rows
eliminate = []# this will store the numbers of the rows to eliminate
for i in range (nr-1):# check all rows, except the last one
for j in range(i+1, nr):# compare to the rows below row i
if A[i] == A[j]: eliminate.append(j)# if row j equals row i, list j to eliminate
return A.delete_rows(eliminate)# eliminate the listed rows and return the resulting submatrix
I hope this helps!