I need to add a new column to a DataFrame where I need to add values by condition. There are only three values in the df['name'] column: 'Enable', 'Disable', NaN. I try to use -> if else, how to change below line of code to use if elif else where:
if df['name'] == 'Enable' then df['status'] = 1, if df['name'] == 'Disable' then df['status'] = 0, if df['name'] == NaN then df['status'] = 2
How to change this part of the code for three values, thanks?
df['status'] = [0 if i == 'Disable' else 1 for i in df['name']]
this case -> Pandas conditional creation of a series/dataframe column not resolve my problem and this is not show how to use if elif else, this case has only two different values.