IconResources
Conduct analysis

Handle empty cells

Identify and manage missing values in your dataset.

Example Data

Follow along with right out of the box example data. Copy following data in the information request of the agent you are working in.



Even in carefully collected datasets, missing values can appear. Sometimes a column is left blank by mistake; other times, the data just doesn’t exist. We need to make thoughtful choices: Should we remove those rows? Should we fill them in with an estimate? Ignoring missing values can lead to inaccurate results or errors.

In this section, you’ll learn how to find, fill, or remove empty cells in your table.

Find missing values

Excel

In Excel, you can filter a column to show only blanks or use conditional formatting to highlight missing cells.

t0 Prompt

Find missing values

Are there any empty cells?

Show me where data is missing

Code

The python code looks as follows:

transactions.isnull()
FunctionDescription
isnull()Shows True where values are missing
notnull()Shows True where values exist

Count missing values

Excel

You can use =COUNTBLANK() in Excel to count empty cells in a range.

t0 Prompt

How many empty values do I have?

Count missing cells

Check for null values in the table

Code

The python code looks as follows:

transactions.isnull().sum()

Remove rows with missing values

Excel

In Excel, you can use filters to hide or delete rows that contain blanks.

t0 Prompt

Remove rows with missing data in column X

Drop all rows that have empty cells

Clean up incomplete rows

Code

The python code looks as follows:

transactions.dropna(inplace=True)
transactions

Fill in missing values

Excel

In Excel, you might type in a replacement value or use formulas like =IF(A1="",0,A1) to fill blanks.

t0 Prompt

Fill missing values with zero

Replace blanks with "Unknown"

Fill empty cells

Code

The python code looks as follows:

transactions.fillna(0, inplace=True)
transactions
MethodDescription
isnull()Marks missing values
sum() after isnull()Counts missing cells per column
dropna()Removes rows with missing values
fillna(value)Fills missing cells with a specified value

On this page