Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个 numpy 数组,想根据索引删除一些列。是否有内置功能或这种操作的优雅方式?
就像是:
arr = [234, 235, 23, 6, 3, 6, 23] elim = [3, 5, 6] arr = arr.drop[elim] output: [234, 235, 23, 3]
使用numpy.delete,它将返回一个新数组:
numpy.delete
import numpy as np arr = np.array([234, 235, 23, 6, 3, 6, 23]) elim = [3, 5, 6] np.delete(arr, elim)