从numpy数组中删除元素的python方法[duplicate]

时间:2021-02-22 20:22:44

This question already has an answer here:

这个问题已经有了答案:

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?

如果数组= np.array([1,2,3,4])和index = np.array([0,1,2])要删除数组中的索引元素,最好的方法是什么?

1 个解决方案

#1


13  

You use numpy.delete:

你使用numpy.delete:

smaller_array = np.delete(array,index)

#1


13  

You use numpy.delete:

你使用numpy.delete:

smaller_array = np.delete(array,index)