Great, we solved the problem! Our dataset was very small, so we could easily identify
NaN values. But what if the dataset was very big? How could we check for
NaN values in that case?
Luckily, there is a trick to do that automatically: we can add
.isnull().values.any() to a DataFrame or a given column to get a
False result. For instance, to check for
NaN values in a whole DataFrame named
cars. We can write:
or to check if a specific column named
vin has any NaN values, we can write:
Both of the lines above return
True if there are any NaN values in the respective object.