I am writing a function to find if two columns satisfy a condition, and if so, I want to return a new column with a statement. I thought I could just do df.apply(function), but it does not seem to work!
def bucketing(df):
if df['NATIONALITY'] == 'RU' and df['CTRY_OF_RESIDENCE'] == 'Russia':
return 'High Risk'
merged.apply(bucketing, axis = 1)
This is my error:
TypeError: unsupported operand type(s) for |: 'str' and 'str'
My expected output would be a new column with the string 'High Risk' returned if the above condition is met.
Is there a more efficient way of doing this?
Thanks