Answers for "python number to categorical into numeric using if else"

2

convert categorical variable to numeric python

# get all categorical columns in the dataframe
catCols = [col for col in df1.columns if df1[col].dtype=="O"]

from sklearn.preprocessing import LabelEncoder

lb_make = LabelEncoder()

for item in catCols:
    df1[item] = lb_make.fit_transform(df1[item])
Posted by: Guest on December-27-2021
-1

how to separate numeric and categorical variables in python

df.loc[:,df.dtypes==np.object]
Posted by: Guest on March-22-2021

Code answers related to "python number to categorical into numeric using if else"

Python Answers by Framework

Browse Popular Code Answers by Language