I am having problems with the Numpy nan_to_num function: I have an array in which the last column contains fewer elements than other columns, and when I import it into Python, it puts "nan" to fill the array. This is just fine, as long as I donβt need to do any other things that deal with Nan.
I try to use "nan_to_num" without success. Most likely, this is a small thing that I am missing, but I can not understand.
Here are some simple inputs and outputs:
input:
a = numpy.array([[1, nan, 3]]) print a numpy.nan_to_num(a) print a
Output
[[ 1. nan 3.]] [[ 1. nan 3.]]
The second "nan" should be zero ... http://docs.scipy.org/doc/numpy/reference/generated/numpy.nan_to_num.html
Thanks in advance.
source share