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, e.g. feez(800, "4 Plan"), returns 3200. However, when I attempt to pass the column values this way I receive the error: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
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 am a newbie and suspect my syntax is poorly written.