let’s say that we have a numpy array and we want to remove all the elements which are equal to a specific value. Below, we will remove all the elements which are equal to 5.
import numpy as np myarr = np.array([1,2,3,4,5,1,2,3,4,5]) myarr
array([1, 2, 3, 4, 5, 1, 2, 3, 4, 5])
# remove all the elements which are equal to 5 myarr = myarr[myarr!=5] myarr
array([1, 2, 3, 4, 1, 2, 3, 4])
As we can see, we removed the 5 element from the array.