Identifying and cleaning missing data
We have already explored some strategies for identifying and cleaning missing values, particularly in Chapter 1, Anticipating Data Cleaning Issues when Importing Tabular Data into pandas. We will polish up on those skills in this recipe. We will do this by exploring a full range of strategies for handling missing data, including using DataFrame means and group means, as well as forward filling with nearby values. In the next recipe, we impute values using k-nearest neighbor.
Getting ready
We will continue working with the National Longitudinal Survey data in this recipe.
How to do it…
In this recipe, we will check key demographic and school record columns for missing values. We'll then use several strategies to impute values for missing data: assigning the overall mean for that column, assigning a group mean, and assigning the value of the nearest preceding non-missing value. Let's get started:
- Import
pandas...