Issue
I would like to know how to get the mean value of a list which contains some NaNs. By using:
np.mean(mylist)
the result as expected gives NaN which is wrong. What should i do to get the mean?
Solution
Use np.nanmean to ignore the NaNs:
np.nanmean(mylist)
For example,
In [108]: np.nanmean([np.nan, 1, 2, np.nan, 3])
Out[108]: 2.0
Answered By - unutbu
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.