I have a 2D numpy array and want to replace each NaN
in each row by the corresponding value from a 1D array. For example, this matrix:
[[1. 2. NaN]
[4. 5. 6.]
[NaN NaN 9.]]
using vector [3. 7. 8.]
would be converted to:
[[1. 2. 8.]
[4. 5. 6.]
[3. 7. 9.]]
How to do it without iterating over indices?