python check for missing rows in sequence code example

Example 1: python find cells with na

In [152]: import numpy as np
In [153]: import pandas as pd
# to return the row and column indices where the value in NaN
In [154]: np.where(pd.isnull(df))
Out[154]: (array([2, 5, 6, 6, 7, 7]), array([7, 7, 6, 7, 6, 7]))

In [155]: df.iloc[2,7]
Out[155]: nan

In [160]: [df.iloc[i,j] for i,j in zip(*np.where(pd.isnull(df)))]
Out[160]: [nan, nan, nan, nan, nan, nan]

Example 2: handling missing dvalues denoted by a '?' in pandas

# Making a list of missing value typesmissing_values = ["n/a", "na", "--"]df = pd.read_csv("property data.csv", na_values = missing_values)