I have a dataframe, with two columns. I am trying to create a third column based on the numbers inside the dataframe. If the number in column b is positive, I want column C to equal column a * b
If the number in column b is negative, I want column c to equal column a * b * 0.95.
an example of what I am trying to get at:
col_a col_b col_c
100. 1. 100
100. -1. -95
100. 10. 1000
100. -10. -950
I have currently tried this:
def profit_calculation(value):
if value<0:
return(a * b * 0.95)
else:
return(a * b)
df['col_c']=df['col_b'].apply(profit_calculation)
But this seems to be incorrect.