从numpy数组中删除元素的pythonic方法

问题描述:

如果您有array = np.array([1,2,3,4])并且您有index = np.array([0,1,2]),并且想要删除数组中的索引元素,那么不循环的最佳方法是什么?

If you have array = np.array([1,2,3,4]) and you have index = np.array([0,1,2]) and you want to remove the index elements in array, what's the best way to do this without looping?

您使用 numpy.delete :

smaller_array = np.delete(array,index)