From the course: Data Analysis with Python and Pandas

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Solution: Missing data

Solution: Missing data

- [Instructor] All right, everybody. Our solution code is up on the right. Let's go ahead and dive into the notebook. All right, so once again, we have our oil series. We've already filled in the missing values, so we just need to recreate this series. And then our first task was to count the number of missing values. So to do this, we just need to do oil_series.isna. Remember, this will return a Boolean series indicating whether or not the value is missing. So, dot sum or count or missing values, we just need to do is an a.sum that will return the number of missing values, which was two in this dataset. To fill in the missing values here, we want to use the fill in a method. And so now that we have our missing count, we just need to fill in the missing values with the median of this series. So we'll use a "fillna" method. So we use a "fillna" method, and we'll pass an oil_series.median, and this will fill in the missing values in this series with the median of the oil price series…

Contents