'numpy.ndarray'对象没有属性'remove'

ber*_*lem 5 python floating-point numpy multidimensional-array

我有一个数组数组,我试图在所有数组中找到最低的非零值。

minima = []
for array in K: #where K is my array of arrays (all floats)
    if 0.0 in array:
        array.remove(0.0)
    minima.append(min(array))

print min(minima)
Run Code Online (Sandbox Code Playgroud)

这产生

AttributeError: 'numpy.ndarray' object has no attribute 'remove'
Run Code Online (Sandbox Code Playgroud)

我以为array.remove()是删除元素的方法。我究竟做错了什么?

ber*_*lem 12

我想我已经想通了。该.remove()方法是一个列表方法,而不是一个 ndarray 方法。因此,通过使用array.tolist()我可以应用该.remove()方法并获得所需的结果。