<jupyter_start><jupyter_text>---title: "Pandas-Missing-Data"author: "<NAME>"date: 2020-09-04description: "-"type: technical_notedraft: false---<jupyter_code>import numpy as np
import scipy.stats
import pandas as pd
import sklearn
df = pd.DataFrame(np.random.randn(5, 3), index=['a', 'c', 'e', 'f',
'h'],columns=['one', 'two', 'three'])

df = df.reindex(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'])

df
#Check for Missing Values
df['one'].isnull()
#Calculations with Missing Data
df['one'].sum()
df['one'].sum()
#Cleaning / Filling Missing Data
#Replace NaN with a Scalar Value
df.fillna(0)
#Fill NA Forward and Backward
df.fillna(method='pad')
#Drop Missing Values
df.dropna()
#Replace Missing (or) Generic Values

df = pd.DataFrame({'one':[10,20,30,40,50,2000], 'two':[1000,0,30,40,50,60]})

df.replace({1000:10,2000:60})<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.2143698468786808, 'fraction_numerical': 0.05889281507656066, 'mean_word_length': 6.589285714285714, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '168980', 'license': 'MIT', 'n_tokens_mistral': 374, 'n_tokens_neox': 332, 'n_words': 79, 'path': 'content/python/pandas/.ipynb_checkpoints/Pandas-Missing-Data-checkpoint.ipynb', 'repo_name': 'Palaniappan12345/mlnotes', 'size': '856'}