Find matching rows in 2 dimensional numpy array

前端 未结 4 1164
心在旅途
心在旅途 2020-11-30 01:38

I would like to get the index of a 2 dimensional Numpy array that matches a row. For example, my array is this:

vals = np.array([[0, 0],
                 [1         


        
4条回答
  •  半阙折子戏
    2020-11-30 02:33

    I believe the numpy_indexed package could do with more clarity in documentation so we could see how best to use it. The npi.contains example above looks like something I could use right away. I have an M X 2 array of integers A and an N X 2 array of integers B. I would like to create an M X 1 array C containing indices of B where A[indxA,0] & A[indxA,1] == B[indxB,0] & B[indxB,1]. Other elements of C = -1. I was thinking that npi.contains might work, but did not find adequate information in the github site to determine whether it could, and if it did, how should I use it.

提交回复
热议问题