ComenzarEmpieza gratis

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.

Este ejercicio forma parte del curso

Dealing with Missing Data in Python

Ver curso

Ejercicio interactivo práctico

Prueba este ejercicio y completa el código de muestra.

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

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

# Print after interpolation
print(airquality[30:40])
Editar y ejecutar código