pandas replace values based on other value code example
Example 1: change column value based on another column pandas
# Changes the 'is_electric' column based on value in the 'type' column
# If the 'type' column == 'electric' then the 'is_electric' becomes 'YES'
df['is_electric']= df['type'].apply(lambda x: 'YES' if (x == 'electric') else 'NO')
Example 2: set value based on column
df.loc[df['c1'] == 'Value', 'c2'] = 10