'numpy.ndarray' object has no attribute 'remove'

Just cast it to a list:

my_list = list(array)

You can then get all the list methods from there.


This does not directly address your question, as worded, but instead condenses some of the points made in the other answers/comments.


The following demonstrates how to, effectively, remove the value 0.0 from a NumPy array.

>>> import numpy as np
>>> arr = np.array([0.1, 0.2, 0.0, 1.0, 0.0]) # NOTE: Works if more than one value == 0.0
>>> arr
array([0.1, 0.2, 0. , 1. , 0. ])
>>> indices = np.where(arr==0.0)
>>> arr = np.delete(arr, indices)
>>> arr
array([0.1, 0.2, 1. ])

Another useful method is numpy.unique(), which, "Returns the sorted unique elements of an array.":

>>> import numpy as np
>>> arr = np.array([0.1, 0.2, 0.0, 1.0, 0.0])
>>> arr = np.unique(arr)
>>> arr
array([0. , 0.1, 0.2, 1. ])

I think I've figured it out. The .remove() method is a list method, not an ndarray method. So by using array.tolist() I can then apply the .remove() method and get the required result.