What does the isnull() function work on?

The project question asked me to determine the number of NaT values in a specific column of a dataframe. My initial idea was to create a counter that would iterate through the column and +=1 wherever a NaT value existed. The pandas documentation mentions that the .isnull() function can take in a scalar or array and return a boolean value or array of boolean values.

I was hoping to use the boolean value to fulfil my conditional statement but it gives me the error 'NaTType object has no attribute .isnull()?

I understand that the other solution is quicker but why doesn’t this work? Thanks in advance :slight_smile:

# this is the solution given in the project solutions

#before I went to the solutions I tried this 

count = 0
for i in range(len(visits_carts)):
    if visits_carts.loc[i, "cart_time"].isnull():


With Pandas, there’s a few ways you could determine if there are any nulls in the dataframe and by column:

#the entire df:

>>age         0
sex         0
bmi         0
children    0
smoker      0
region      0
charges     0
dtype: int64

#the total sum by df:


#the sum of nulls by column:


#the boolean way:


#by column:


You can always check the docs: