isnull() function is not identifying missing values in my data

Viewed 191

I am using df[''].isnull() on a data frame I am currently using pulled from a CSV. It is practice data that has lots of missing values and errors intentionally, however, pandas cannot identify the missing values in the DOB column, having verified there are missing values based on opening the CSV and seeing the empty cells under the DOB column.

df['DOB'].isnull().sum()
Output: 0
1 Answers

You can first convert column to datetimes by to_datetime with errors='coerce' for parse non datetime-like to NaT for misisng values and then count:

df['DOB'] = pd.to_datetime(df['DOB'], errors='coerce')

out = df['DOB'].isnull().sum()
Related