What's the difference between pandas.isna and numpy.isnan?

Viewed 1872

I checked docs of pandas isna and numpy isnan.

They seemed to say thaat numpy.isnan detects NaN only and pandas.isna detects both NaN and None type.

Is that so?

1 Answers

Yes, this is correct.
np.isnan checks if your value is np.nan or your iterable (array,list) contains np.nan.
For example (from their documentation):
np.isnan([np.log(-1.),1.,np.log(0)]) results array([ True, False, False]) this is because np.log(-1) is not defined and results np.nan. np.isnan does not detects python None.

pandas.isna on the other hand lays above numpy and detects both np.nan and None values.

Related