Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Missing values
5. Automatic check for NaN values
Duplicate rows
Outliers
Joining datasets
Summary

Instruction

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 True/False result. For instance, to check for NaN values in a whole DataFrame named cars. We can write:

cars.isnull().values.any()

or to check if a specific column named vin has any NaN values, we can write:

cars['vin'].isnull().values.any()

Both of the lines above return True if there are any NaN values in the respective object.

Exercise

Check if there are any NaN values in the experience column of ticket_statistics. Return True or False.

The result we got is False. This means that there are no NaN values in that particular column.

Stuck? Here's a hint!

To access the given column, use:

ticket_statistics['experience']