I tried to create a new column for my dataset with conditions, however, my jupyter shows the erroe:ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()
.
Here is my target:
Create a new column called ‘ind_comp’ that displays either 'Above' or 'Below'. Companies with 'pbk' equal to or higher than 'ind_pbk' should have a value‘Above’. The remainder should be ‘Below’.
And my Codes:
def cat(col1,col2):
if col1-col2>=0:
result="Above"
else:
result= "Below"
return result
rsh_df['ind_comp']=cat(rsh_df['pbk'],rsh_df['ind_pbk'])
How can I fix this? Thanks