I am having trouble "applying" a custom function in Pandas. When I test the function, directly passing the values it works and correctly returns the response. However, when I attempt to pass the column values this way
def feez (rides, plan):
pmt4 = 200
inc4 = 50 #number rides included
min_rate4 = 4
if plan == "4 Plan":
if rides > inc4:
fee = ((rides - inc4) * min_rate4) + pmt4
else:
fee = pmt4
return (fee)
else:
return 0.1
df['fee'].apply(feez(df.total_rides, df.plan_name))
I receive the error:
"The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()."
Passing the values directly works, i.e. feez (800, "4 Plan"), returns 3200
However, I receive errors when I try to apply the function above.
I am a newbie and suspect my syntax is poorly written. Any ideas much appreciated. TIA. Eli