Handling missing values in pandas

In this section, we will explore how we can use various pandas techniques to handle the missing data in our datasets. We will learn how to find out how much data is missing, and from which columns. We'll see how to drop rows or columns where all or a lot of records are missing data. We'll also learn how, instead of dropping data, we can also fill in the missing records with zeros or the mean of the remaining values.

We will start by importing the pandas module into our Jupyter notebook:

import pandas as pd

We will then read in our CSV dataset:

data = pd.read_csv('data-titanic.csv')data.head()

This dataset ...

Get Mastering Exploratory Analysis with pandas now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.