selecting rows in numpy ndarray based on the value of two columns

后端 未结 2 374
别那么骄傲
别那么骄傲 2021-01-31 10:46

I have a big np.ndarray (3600000,3), the HUE, the VALUE, and an associated CLASS number. For each pairs of HUE a

2条回答
  •  [愿得一人]
    2021-01-31 10:53

    Try this code:

     x[x[:, 2] == class_number[:, :2]
    

    where x is np.ndarray

     x[:, 2] == class_number
    

    contains true/false that means whether the last is class_number or not.

    You need to take a look at: Boolean indexing in http://wiki.scipy.org/Cookbook/Indexing

    Moved from comment.

提交回复
热议问题