<jupyter_start><jupyter_text>How to Tackle null values in a dataset<jupyter_code>import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
df = pd.read_csv('../Datasets/titanicKaggle.csv')
df.head()
df.tail()
sns.heatmap(df.isna())
df[df['Age'].isna()]['Age']
df['Age'].fillna(value ='good')
# df['Age'].fillna(value ='good',inplace=True) Use inplace to reflect in df
df.isna().sum()
df.fillna(method='backfill').head(10)
df.fillna(method='bfill').head(10)
df.fillna(method='ffill').head(10)
df.Age.median()
df['Age'].fillna(value = df['Age'].median() ,inplace=True)
df.head(10)
df.isna().sum()<jupyter_output><empty_output><jupyter_text>How to use dropna<jupyter_code>df.shape
df.dropna().shape<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.19210526315789472, 'fraction_numerical': 0.010526315789473684, 'mean_word_length': 7.6477272727272725, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '404481', 'license': 'Unlicense', 'n_tokens_mistral': 323, 'n_tokens_neox': 309, 'n_words': 53, 'path': 'Pandas - Crash Course/JP Nan/PandasL9.ipynb', 'repo_name': 'geekymano/Machine-Learning', 'size': '760'}