Question: Need help getting this to work: import sys sys.path.append('/Users/...') import warnings warnings.simplefilter(ignore) import pandas as pd data0=pd.read_excel('ks-projects-cleaned1.xlsx') data_rule=data0 # We keep a copy of

Need help getting this to work:

import sys
sys.path.append('/Users/...')

import warnings
warnings.simplefilter("ignore")  

import pandas as pd

data0=pd.read_excel('ks-projects-cleaned1.xlsx')

data_rule=data0 # We keep a copy of the original data for association rule analysis, because we don't need to fill missing values.

data0=data0.fillna(data0.mean()) #Replace missing values of numeric attributes with the mean of the attribute

data0=data0.fillna('Missing') #Replace missing values of categorical attributes with string 'Missing'

data_clu=data0 #keep a copy of the data for clustering because it will be further processed for clustering.

data0.head(9).transpose()

2 4 5 0 1 currency GBP CAD USD USD GBP USD

from cat_to_dummy_Functions1 import cat_to_dummy   data0=cat_to_dummy(data0,['state','country']) #Convert categorical values to 0/1. Used for classification & numeric prediction    data0.head().transpose()

Here is the function:

def cat_to_dummy(data,list):    import pandas as pd        for i in list:            data=pd.concat([data, pd.get_dummies(data[i], prefix = i)], axis = 1)    data=data.drop(list, axis = 1)        return data

Here is what I am currently getting:

goal 1000 1000 2500 2500 5000 200000 12000 2500 13500 12000 50000

Here is the data:

pledged 000 state failed failed failed backers 0 0 0 GB CA  

 

2 4 5 0 1 currency GBP CAD USD USD GBP USD goal 1000 1000 2500 2500 5000 200000 12000 2500 13500 12000 50000 pledged 000 state failed failed failed backers 0 0 0 GB CA US 0 0 country usd pledged 0 3 data0.head().transpose() 0 0 US 0 0 0 137 failed failed failed failed failed failed 0 0 GB 0 0 US 6 0 7 8 USD EUR CAD 0 US 0 0 2 0 IT CA 0 0 : from cat_to_dummy_Functions import cat_to_dummy data=cat_to_dummy (data0, ['currency', 'state', 'country']) #Convert categorical values to 0/1. Used for classification & numeric prediction

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!