I have a DataFrame named 'df' in Python that has a column named 'base', this column cotains three values (1, 2 and 3) in a numerically way, I want to change the value 1 and 2 by 0 and the value 3 by 1. How can I do this?
CodePudding user response:
try this:
df['base'].replace({1: 0, 2: 0, 3: 1})
Dicts can be used to specify different replacement values for different existing values
