O'Reilly logo

Learning pandas - Second Edition by Michael Heydt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Performing interpolation of missing values

Both DataFrame and Series have an .interpolate() method that, by default, performs a linear interpolation of missing values:

The value of the interpolation is calculated by taking the first value before and after any sequence of the NaN values, and then incrementally adding that value from the start and substituting the NaN values. In this case, 2.0 and 1.0 are the surrounding values, resulting in (2.0 - 1.0)/(5-1) = 0.25, which is then added incrementally through all the NaN values.

This is important. Imagine if your data represents an increasing set of values, such as increasing temperature during ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required