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]]
CodePudding user response:
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]])