For example:
scala> val my_array = Array(4,5,Double.NaN,6,5,6, Double.NaN)
my_array: Array[Double] = Array(4.0, 5.0, NaN, 6.0, 5.0, 6.0, NaN)
scala> my_array.count(_ == Double.NaN)
res13: Int = 0
I understand that two Double.NaN
are not equal to each other
scala> Double.NaN == Double.NaN
res14: Boolean = false
and therefore, I get the result that I get, but I can't find a function that would tell me the number of Double.NaN
s, what am I missing?
In python
the behaviour would look like this:
In [43]: import numpy as np
In [44]: a = np.array([5,np.nan,5,7,4,np.nan])
In [45]: np.isnan(a)
Out[45]: array([False, True, False, False, False, True], dtype=bool)
In [46]: np.isnan(a).sum()
Out[46]: 2