[Numpy-discussion] How to subset a matrix according to some criterion?
jni.soma at gmail.com
Sun Dec 3 17:06:30 EST 2017
selector = target != 2
data, target = data[selector], target[selector]
On 4 Dec 2017, 8:38 AM +1100, Peng Yu <pengyu.ut at gmail.com>, wrote:
> 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()
> NumPy-Discussion mailing list
> NumPy-Discussion at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion