What is the output of np.nanmean([1, np.nan, 3])?
Correct answer
B. 2.0
12 views
B. 2.0
12 views
The result is 2.0. np.nanmean() ignores NaN values and averages the rest: (1 + 3) / 2 = 2.0.
Ordinary np.mean() on the same data would return nan, because any arithmetic involving NaN produces NaN.
Keep preparing with more Data Science MCQs on MCQsExam.com.
Not sure why the answer is B? Ask here and get an explanation.