The code is given below. I want to exclude two columns name 'Card Type' and 'Risk Value' from the label encoding code. How to exclude those? The below code encodes all object types into numerical. The columns are Alert number Job, Loan, City, Date, Card Type, Gender, Income level, EstimatedSalary, Risk Value
le = LabelEncoder() objList = bank_dataset.select_dtypes(include="object").columns for feat in objList: bank_dataset[feat] = le.fit_transform(bank_dataset[feat].astype(str))
Use:
objList = bank_dataset.select_dtypes(include="object").columns objList = objList.difference(['Card Type','Risk Value'], sort=False)
Or:
objList = [x for x in objList if x not in ['Card Type','Risk Value']]
2.1m questions
2.1m answers
60 comments
57.0k users