In pandas
when we are trying to cast a series which contains NaN
values to integer with a snippet such as below
df.A = df.A.apply(int)
, i often see an error message
ValueError: cannot convert float NaN to integer
I understand that NaN
values can't be converted to integer. But i am curious about the ValueError
thrown in this case. it says float NaN can't be converted to integer.
Is there any specific reason why NaN
values are treated as float objects? or is this the case of some issue with the error messages displayed?