Issue
I have a numpy matrix with 2 axis (row and columns) and an array. I want to remove the row in the matrix that equals to the array. For example, if the matrix is
[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
And the array is [1, 2, 3], then the output should be:
[[4, 5, 6],
[7, 8, 9]]
Solution
Use:
a[~(a == b).all(1)]
Example:
a = np.arange(1, 10).reshape((3, 3))
b = np.arange(1, 4)
a[~(a == b).all(1)]
array([[4, 5, 6],
[7, 8, 9]])
Answered By - Psidom
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.