/exno1

data process

Primary LanguageJupyter Notebook

Exno:1

Data Cleaning Process

AIM

To read the given data and perform data cleaning and save the cleaned data to a file.

Explanation

Data cleaning is the process of preparing data for analysis by removing or modifying data that is incorrect ,incompleted , irrelevant , duplicated or improperly formatted. Data cleaning is not simply about erasing data ,but rather finding a way to maximize datasets accuracy without necessarily deleting the information.

Algorithm

STEP 1: Read the given Data

STEP 2: Get the information about the data

STEP 3: Remove the null values from the data

STEP 4: Save the Clean data to the file

STEP 5: Remove outliers using IQR

STEP 6: Use zscore of to remove outliers

Coding and Output

import pandas as pd
df=pd.read_csv("SAMPLEIDS.csv")
df

image

df.head()

image

df.tail()

image

df.isnull()

image

df.isnull().sum()

image

df.isnull().any()

image

df.dropna(axis=0)

image

df.fillna(0)

image

df.fillna(method = 'ffill')

image

df.fillna(method = 'bfill')

image

df_dropped = df.dropna()
df_dropped

image

df.fillna({'GENDER':'MALE','NAME':'SRI','ADDRESS':'POONAMALEE','M1':98,'M2':87,'M3':76,'M4':92,'TOTAL':305,'AVG':89.999999})

image

import pandas as pd
ir=pd.read_csv('iris.csv')
ir

image

ir.describe()

image

import seaborn as sns
sns.boxplot(x='sepal_width',data=ir)

image

c1=ir.sepal_width.quantile(0.25)
c3=ir.sepal_width.quantile(0.75)
iq=c3-c1
print(c3)

image

rid=ir[((ir.sepal_width<(c1-1.5*iq))|(ir.sepal_width>(c3+1.5*iq)))]
rid['sepal_width']

image

delid=ir[~((ir.sepal_width<(c1-1.5*iq))|(ir.sepal_width>(c3+1.5*iq)))]
delid

image

sns.boxplot(x='sepal_width',data=delid)

image

import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import scipy.stats as stats
dataset=pd.read_csv("heights.csv")
dataset

image

z = np.abs(stats.zscore(dataset['height']))
z

image

Result

Thus we have cleaned the data and removed the outliers by detection using IQR and Z-score method.