Here is a simple numpy array:
import numpy as np
x = np.array([15, 22, 3])
I want to transform the second value into nan:
x[1] = np.nan
It returns the following error:
ValueError: cannot convert float NaN to integer
print(type(x[1])) # this returns "<class 'numpy.int32'>"
I managed to replace the required value with NaN by transforming the array of ints into an array of floats.
But still. Why is numpy telling me that I can't convert a float NaN when I'm actually trying to convert an int?
Thank you