FINDING MISSING VALUES IN PANDAS
Listing 3.29 displays the contents of employees2.csv and Listing 3.30 displays the contents of missing_values.py that illustrates how to display rows of a DataFrame that have missing values in a Pandas DataFrame.
LISTING 3.29: employees2.csv
name,year,month Jane-Smith,2015,Aug Jane-Smith,2015,Aug Dave-Smith,2020, Dave-Stone,Apr Jane-Jones,2018,Dec Jane-Stone,2017,Feb Jane-Stone,2017,Feb Mark-Aster,Oct Jane-Jones,NaN,Jun
LISTING 3.30: missing_values.py
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
df = pd.read_csv("employees2.csv")
print("=> contents of CSV file:")
print(df)
print()
#NA: Not Available (Pandas)
#NaN: Not a Number (Pandas)
#NB: NumPy uses np.nan() to check for NaN values
df = pd.read_csv("employees2.csv")
print("=> contents of CSV file:")
print(df)
print()
print("=> any NULL values per column?")
print(df.isnull().any())
print()
print("=>...