I have a dataframe
df = pd.DataFrame({
    'a': [-1.5, 2.5, 2.0],
    'b': [0.25, -2.75, 3.5],
    'c': [1.25, -0.75, 2.0]
})
    a     b     c
  -1.5  0.25  1.25
   2.5 -2.75 -0.75
   2.0  3.50  2.00
I want to create a new dataframe 'df_fun' by applying the below function on 'df'.
def fun(x):
  if (x < 0) :
    return 1
  else :
    return 2*x
df_fun = df.apply(fun, axis = 1)
However, I’m getting the below error.
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
Appreciate the answers/responses.
 
    