Python(numpy):按索引删除列

时间:2013-03-01 03:14:07

标签: python numpy

我有一个numpy数组,想根据索引删除一些列。是否有内置功能或者这种操作的优雅方式?

类似的东西:

arr = [234, 235, 23, 6, 3, 6, 23]
elim = [3, 5, 6]

arr = arr.drop[elim]

output: [234, 235, 23, 3]

1 个答案:

答案 0 :(得分:10)

使用numpy.delete,它将返回一个新数组:

import numpy as np
arr = np.array([234, 235, 23, 6, 3, 6, 23])
elim = [3, 5, 6]
np.delete(arr, elim)