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()
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:
Here is the data:
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started