if condition for dataframe variable in python code example
Example: if condition dataframe python
df.loc[df['age1'] - df['age2'] > 0, 'diff'] = df['age1'] - df['age2']
df.loc[df['age1'] - df['age2'] > 0, 'diff'] = df['age1'] - df['age2']