<jupyter_start><jupyter_text>DAY3<jupyter_code>import numpy as np
import pandas as pd
df=pd.DataFrame([[99,87],[np.nan,92],[np.nan,56]]
               ,columns=['1st Term','2nd Term'],
                index=['John','Dave','Bright']
               )
df
#check missing values using isnull() function
df.isnull()
#Create series to find all records where 1st term is NULL
t=(df['1st Term']).isnull()
t

type(t)
df[t]
#Check using notnull() function
df.notnull()
#fillna(): to replace NA with fucntion values

df.fillna(0)
#replace using backfill method with next values
df.fillna(method="bfill")
#replace using forwardfill method with previous value
df.fillna(method="pad")
#fill values in a certain column
#inplace=True, performs it on data and doesnt return anything while inplace=False creates a new copy of data
df["1st Term"].fillna('No values', inplace=True)
df
#replace() function to replace values
df.replace(to_replace='No values',value=-99)
#interpolate()
df.interpolate(method='linear',limit_direction='forward')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1325071496663489, 'fraction_numerical': 0.016205910390848427, 'mean_word_length': 5.363636363636363, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '382438', 'license': 'MIT', 'n_tokens_mistral': 350, 'n_tokens_neox': 337, 'n_words': 103, 'path': 'Code/Day3 Handling_Null_ Values.ipynb', 'repo_name': 'chetnashahi/100daysofML', 'size': '1049'}