Answers for "transform numeric to date to categorical data"

1

panda categorical data into numerica

sex = train_dataset['Sex'].replace(['female','male'],[0,1])
print(sex)
Posted by: Guest on March-04-2021
0

To convert categorical data to numerical

cat_cols = ['Item_Identifier', 'Item_Fat_Content', 'Item_Type', 'Outlet_Identifier', 
         'Outlet_Size', 'Outlet_Location_Type', 'Outlet_Type', 'Item_Type_Combined']
enc = LabelEncoder()

for col in cat_cols:
    train[col] = train[col].astype('str')
    test[col] = test[col].astype('str')
    train[col] = enc.fit_transform(train[col])
    test[col] = enc.transform(test[col])
Posted by: Guest on May-24-2021

Code answers related to "transform numeric to date to categorical data"

Browse Popular Code Answers by Language