I have an array that contains some NaN values. I want to multiply column elements, but I am getting NaN as the answer due to NaN. How can I treat NaN as 1 while multiplying?

E.g.

[[ 1., 2., 3.],

[ 4., nan, 6.],

[ 7., 8., 9.],

[10., 11., nan]]

The prod() function of Numpy returns :

>>> np.prod(aa, axis=0)

array([280., nan, nan])

E.g.

[[ 1., 2., 3.],

[ 4., nan, 6.],

[ 7., 8., 9.],

[10., 11., nan]]

The prod() function of Numpy returns :

>>> np.prod(aa, axis=0)

array([280., nan, nan])