check for missing values in pandas

df.isna().sum()

Here is what the above code is Doing:
1. We’re creating a new dataframe called df_no_missing.
2. We’re using the .isna() method to check for missing values.
3. We’re using the .sum() method to count the number of missing values.

The output of the above code is a table that shows us the number of missing values in each column.

We can see that the ‘Age’ column has 177 missing values, the ‘Cabin’ column has 687 missing values, and the ‘Embarked’ column has 2 missing values.

The ‘Age’ and ‘Cabin’ columns have a lot of missing values, so we’ll drop them from our dataset.

The ‘Embarked’ column only has 2 missing values, so we’ll fill those in with the mode of the column.