[Numpy-discussion] How to subset a matrix according to some criterion?

Peng Yu pengyu.ut at gmail.com
Sun Dec 3 16:38:02 EST 2017


Hi, I'd like to select the rows of 'data' for which the corresponding
elements in 'target' is not 2. Could anybody let know what is the best
way (with the least code) to do conditional subsetting like this with
numpy objects? Thanks.

from sklearn import datasets
data, target = datasets.load_iris()

-- 
Regards,
Peng


More information about the NumPy-Discussion mailing list