我现在正在使用这种方法:
data = np.array([[0, 0, 0, 0, 1, 2, 3, 4, 5, 0, 6, 0, 0], [0, 0, 0, 0, 1, 2,3, 4, 5, 0, 6, 0, 0]])
index = 0
idx = []
for img in range(len(data)):
img_raw = np.any(data[img])
if img_raw == 0.0:
idx.append(index)
index+=1
data = np.delete(data, idx, axis=0)
有人知道更好的方法吗?
data = np.array([])
直接清空其内容。 - Stefan Pochmannnp.delete(data,[0,1,2,3,9,11,12],axis = 1)
将删除选定的列。 - hpaulj