Get startedGet started for free

Impute with interpolate method

Time-series data have trends of ups and downs against time. For this, filling flat series of values using methods like forward fill or backward fill is not suitable. A more apt imputation would be to use methods like linear or quadratic imputation, where the values are filled with incrementing or decrementing values.

In this exercise, you will work with the .interpolate() method on the airquality DataFrame. You will use linear, quadratic and nearest methods. You can also find the detailed list of strategies for interpolation here.

This exercise is part of the course

Dealing with Missing Data in Python

View Course

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Print prior to interpolation
print(airquality[30:40])

# Interpolate the NaNs linearly
airquality.interpolate(___, inplace=True)

# Print after interpolation
print(airquality[30:40])
Edit and Run Code