Coder Social home page Coder Social logo

odd2023-datascience-ex01's Introduction

Ex-01 Data_Cleansing

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

CODE :

LOAN_DATA.CSV:

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

df.head(10)

df.info()

df['Loan_ID']=df['Loan_ID'].fillna(df['Dependents'].mode()[0])
df['Dependents']=df['Dependents'].fillna(df['Dependents'].mode()[0])
df['Education']=df['Education'].fillna(df['Dependents'].mode()[0])
df['Self_Employed']=df['Self_Employed'].fillna(df['Self_Employed'].mode()[0])
df['Gender']=df['Gender'].fillna(df['Gender'].mode()[0])
df.head()

df['ApplicantIncome']=df['ApplicantIncome'].fillna(df['ApplicantIncome'].mean())
df['Loan_Amount_Term']=df['Loan_Amount_Term'].fillna(df['Loan_Amount_Term'].mean())
df['LoanAmount']=df['LoanAmount'].fillna(df['LoanAmount'].mean())
df.head()

df['Credit_History']=df['Credit_History'].fillna(df['Credit_History'].median())
df.head()

df.info()

df.isnull().sum()



DATA_SET.CSV:

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

df.head(10)

df.info()

df.isnull()

df.isnull().sum()

df['show_name']=df['show_name'].fillna(df['aired_on'].mode()[0])
df['aired_on']=df['aired_on'].fillna(df['aired_on'].mode()[0])
df['original_network']=df['original_network'].fillna(df['aired_on'].mode()[0])
df.head()

df['rating']=df['rating'].fillna(df['rating'].mean())
df['current_overall_rank']=df['current_overall_rank'].fillna(df['current_overall_rank'].mean())
df.head()

df['watchers']=df['watchers'].fillna(df['watchers'].median())
df.head()

df.info()

df.isnull()

df.isnull().sum()

##OUTPUT :

FOR LOAN_DATA:

DATA

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

MODEL

NON NULL BEFORE

df.info()

MODEL

MODE

df['Loan_ID']=df['Loan_ID'].fillna(df['Dependents'].mode()[0]) df['Dependents']=df['Dependents'].fillna(df['Dependents'].mode()[0]) df['Education']=df['Education'].fillna(df['Dependents'].mode()[0]) df['Self_Employed']=df['Self_Employed'].fillna(df['Self_Employed'].mode()[0]) df['Gender']=df['Gender'].fillna(df['Gender'].mode()[0]) df.head()

MODEL

MEAN

df['ApplicantIncome']=df['ApplicantIncome'].fillna(df['ApplicantIncome'].mean()) df['Loan_Amount_Term']=df['Loan_Amount_Term'].fillna(df['Loan_Amount_Term'].mean()) df['LoanAmount']=df['LoanAmount'].fillna(df['LoanAmount'].mean()) df.head()

MODEL

MEDIAN

df['Credit_History']=df['Credit_History'].fillna(df['Credit_History'].median()) df.head()

MODEL

NON NULL AFTER

df.info()

MODEL

df.isnull().sum()

MODEL

FOR DATA_SET :

DATA

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

MODEL

NON NULL BEFORE

df.info()

MODEL

df.isnull()

MODEL

df.isnull().sum()

MODEL

MODE

df['show_name']=df['show_name'].fillna(df['aired_on'].mode()[0]) df['aired_on']=df['aired_on'].fillna(df['aired_on'].mode()[0]) df['original_network']=df['original_network'].fillna(df['aired_on'].mode()[0]) df.head()

MODEL

MEAN

df['rating']=df['rating'].fillna(df['rating'].mean()) df['current_overall_rank']=df['current_overall_rank'].fillna(df['current_overall_rank'].mean()) df.head()

MODEL

MEDIAN

df['watchers']=df['watchers'].fillna(df['watchers'].median()) df.head()

MODEL

NON NULL AFTER

df.info()

MODEL

df.isnull()

MODEL

df.isnull().sum()

MODEL

##RESULT:

Thus,the given data is read,cleansed and the cleaned data is saved into the file..!!!

odd2023-datascience-ex01's People

Contributors

soundariyan18 avatar karthi-govindharaju avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.