SyntaxFix
Write A Post
Hire A Developer
Questions
Note the tilda that reverses the selection. It uses pandas methods (i.e. is faster than if/else).
if
else
df.loc[(df['c1'] == 'Value'), 'c2'] = 10 df.loc[~(df['c1'] == 'Value'), 'c2'] = df['c3']