Numpy array of multiple indices replace with a different matrix

前端 未结 2 1131
失恋的感觉
失恋的感觉 2021-01-21 19:26

I have an array of 2d indices.

indices = [[2,4], [6,77], [102,554]]

Now, I have a different 4-dimensional array, arr, and I want to only extrac

2条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-21 20:19

    Try using the take function of numpy arrays. Your code should be something like:

    outputarray= np.take(arr,indices)
    

提交回复
热议问题