I have a two-dimensional numpy-array. It has a shape of (6994, 6994). There are many values of -1000 which I would like to encode as NAN. I tried:
array[array == -1000] = np.NAN, but this gives me the error cannot convert float NaN to integer
When I tried to write a function:
def valtona(array, val):
for i in array:
for j in array:
if array[i,j] == -1000:
array[i,j] = np.NAN
I get:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
I know there are some questions out there regarding the same issue, but I still didn't manage to fix it.
for i in range(6994): for j in range(6994):.np.nanis a float. Your array is integer. For thesklearnuse which is more useful?