0
0
Data Analysis Pythondata~5 mins

Identifying missing values (isnull, isna) in Data Analysis Python

Choose your learning style9 modes available
Introduction

We use these functions to find missing or empty spots in our data. This helps us clean and understand the data better.

When checking if survey answers are missing before analysis.
When cleaning a sales dataset to find missing prices or quantities.
When preparing data for machine learning and need to handle empty values.
When exploring a dataset to see which columns have missing information.
Syntax
Data Analysis Python
DataFrame.isnull()
DataFrame.isna()

Both isnull() and isna() do the same thing in pandas.

They return a DataFrame of the same shape with True where values are missing and False otherwise.

Examples
This shows True where values are missing in the DataFrame.
Data Analysis Python
import pandas as pd

data = {'Name': ['Anna', 'Bob', None], 'Age': [25, None, 30]}
df = pd.DataFrame(data)

print(df.isnull())
This does the same as isnull(), showing missing values.
Data Analysis Python
print(df.isna())
Check missing values only in the 'Age' column.
Data Analysis Python
print(df['Age'].isnull())
Sample Program

This program creates a small table with some missing values. Then it finds and prints where the missing values are.

Data Analysis Python
import pandas as pd

data = {'Product': ['Book', 'Pen', 'Notebook', None], 'Price': [12.99, None, 5.49, 7.99]}
df = pd.DataFrame(data)

missing_values = df.isnull()
print(missing_values)
OutputSuccess
Important Notes

Missing values can be None, NaN, or NaT in pandas.

Use these functions before filling or dropping missing data to understand where they are.

Summary

isnull() and isna() help find missing data in tables.

They return True for missing spots and False for filled spots.

Use them to check data quality before analysis or cleaning.