pandas.isnull() (also pd.isna() , in newer versions) checks for missing values ββin both numeric and string / object arrays. From the documentation, it checks:
NaN in numeric arrays, None / NaN in arrays of objects
Quick example:
import pandas as pd import numpy as np s = pd.Series(['apple', np.nan, 'banana']) pd.isnull(s) Out[9]: 0 False 1 True 2 False dtype: bool
The idea of ββusing numpy.nan to represent missing values ββis what pandas introduced, so pandas has tools to solve it.
Datetime (if you use pd.NaT you do not need to specify dtype)
In [24]: s = Series([Timestamp('20130101'),np.nan,Timestamp('20130102 9:30')],dtype='M8[ns]') In [25]: s Out[25]: 0 2013-01-01 00:00:00 1 NaT 2 2013-01-02 09:30:00 dtype: datetime64[ns]'' In [26]: pd.isnull(s) Out[26]: 0 False 1 True 2 False dtype: bool
Marius Sep 08 '13 at 23:33 2013-09-08 23:33
source share