Handle Nulls¶
Load Titanic Dataset¶
import seaborn as sns
titanic = sns.load_dataset('titanic')
titanic.head()
Count Nulls For Each Column¶
titanic.isnull().sum()
Visualize Rows With Nulls¶
titanic[titanic.isnull().any(axis=1)]
Impute Replacement Values¶
Use mean
to replace numeric values.
titanic.age = titanic.age.fillna(titanic.age.mean())
titanic
titanic.isnull().sum()
Drop Rows with Nulls¶
titanic = titanic.dropna(how='any', axis=0)
titanic.isnull().sum()
titanic