I have a list of integers which represent positions in a matrix (centre). For example,
centre = [2, 50, 100, 89]
I also have two numpy matrices, X and Y. I need to delete all of the rows from the matrix if the number is in the centre. I can do this:
for each in centre:
x = numpy.delete(x, (each), axis=0)
However, the numbers will all be out as the index's will all be out. So, how can I do this?
Just do the
deletein one call:You question is a little confusing. I'm assuming that you want to delete rows by index number, not by some sort of content (not like the list
find).However if you must iterate (as with a list) do it in reverse order - that way indexing doesn't get messed up. You may have to sort the indices first (
np.deletedoesn't require that).A list example that has to be iterative:
=============
With a list input like this,
np.deletedoes the equivalent of: