Handling missing data while reading

The read_excel method has a list of values that it will consider as missing and will then set the values to NaN. We can add this when passing a list of values by using the na_values parameter, as shown in the following code:

df = pd.read_excel('IMDB.xlsx', sheetname= 0, na_values=[' '])

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.