Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Replace Missing Values with Interpolation | Data Cleaning
Preprocessing Data

bookReplace Missing Values with Interpolation

Another approach to deal with numerical data is using interpolation. Each NaN value will be replaced with the result of interpolation between the previous and the next entry over the column. Let's apply the interpolate() function to numeric column Age by setting the limit direction to forward. This means that linear interpolation is applied from the first line to the last.

1
data = data.interpolate(method = 'linear', limit_direction = 'forward')
copy
Task

Swipe to start coding

Fill the empty places in the code. Compare the data in Age column before and after using interpolation (look at the last 10 rows).

Solution

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 2. ChapterΒ 6
single

single

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

Suggested prompts:

Summarize this chapter

Explain the code in file

Explain why file doesn't solve the task

close

Awesome!

Completion rate improved to 5.56

bookReplace Missing Values with Interpolation

Swipe to show menu

Another approach to deal with numerical data is using interpolation. Each NaN value will be replaced with the result of interpolation between the previous and the next entry over the column. Let's apply the interpolate() function to numeric column Age by setting the limit direction to forward. This means that linear interpolation is applied from the first line to the last.

1
data = data.interpolate(method = 'linear', limit_direction = 'forward')
copy
Task

Swipe to start coding

Fill the empty places in the code. Compare the data in Age column before and after using interpolation (look at the last 10 rows).

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

close

Awesome!

Completion rate improved to 5.56
SectionΒ 2. ChapterΒ 6
single

single

some-alt