How to do it...

First, let's import the necessary Python libraries:

  1. Import the required Python libraries:
import pandas as pdimport matplotlib.pyplot as plt
  1. Let's load a few variables from the dataset into a pandas dataframe and inspect the first five rows:
cols = ['AGE', 'NUMCHLD', 'INCOME', 'WEALTH1', 'MBCRAFT', 'MBGARDEN', 'MBBOOKS', 'MBCOLECT', 'MAGFAML','MAGFEM', 'MAGMALE']
data = pd.read_csv('cup98LRN.txt', usecols=cols)data.head()

After loading the dataset, this is how the output of head() looks like when we run it from a Jupyter Notebook:

  1. Let's calculate the number of missing values in each variable:
data.isnull().sum()

The number ...

Get Python Feature Engineering Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.