Reputation: 494
I have a dataset that is labeled with the classes 0-3 and I'm trying to change it so that I can run my classifier with binary labels. So I want to change classes 2 and 3 to class 1. Is there a quick way to do it? Thanks for help
Upvotes: 1
Views: 2668
Reputation: 148
df['column'] = np.where(df.column == "class0", "class0", "class1")
This will effectively leave class0 to class0 only but the remaining classes will be labeled class1.
Upvotes: 0
Reputation: 610
I guess you have a column that contains 3 types, so below code simply do the task;
df['column'] = df['column'].map({'first_element':1, 'second_element':2,'third_element':3})
Upvotes: 2