From the course: Python Data Analysis

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Filling missing values

Filling missing values - Python Tutorial

From the course: Python Data Analysis

Start my 1-month free trial

Filling missing values

- [Instructor] We pick up where we left and load temperature data for Pasadena, California using our getweather module. This is a time series, a sequence of values, organized chronologically, usually with equal cadence, that is the same time interval between every two consecutive samples. To get a sense of the data, one of them begins by computing its average value and perhaps its extreme, the minimum and maximum. With NumPy, we can use mean, min, and max. But wait, in this case, we seem to get NaNs. What's going on? It shouldn't be surprising, if we remember that the data contains missing values, which are indeed represented as NaNs. And NaNs can't really participate in any mathematical operation, NaN plus one is still NaN. In fact, how many do we have? The NumPy function isnan, creates a Boolean array of NaN-ness, so to speak. We can then count the instances of true in this array by using a neat trick. If we do…

Contents