pphero0287
pphero0287

Reputation: 47

'ignore nan' in numpy functions

The elementary functions in numpy, like mean() and std() returns np.nan when encounter np.nan. Can I make them ignore it?

Upvotes: 0

Views: 1841

Answers (1)

CutePoison
CutePoison

Reputation: 5355

The "normal" functions like np.mean and np.std evalutates the NaN i.e the result you've provided evaluates to NaN.

If you want to avoid that, use np.nanmean and np.nanstd. Note that since you have only one non-nan element the std is 0, thus you are dividing by zero.

Upvotes: 2

Related Questions