here is my code
def calculsComplexesPlusieursColonnes(total_bill,tip,sex):
if sex=="Female":return total_bill+tip
else : return total_bill+2*tip
tips['résultat'] = tips.apply(lambda row: calculsComplexesPlusieursColonnes(row['total_bill'], row['tip'],row['sex']), axis=1)
tips=tips.assign(résultat_bis=lambda row: calculsComplexesPlusieursColonnes(row.total_bill,row.tip,row.sex))
I try 2 ways of creating a new variable using a function : the first one works fine (var résultat) but the second one (var résultat_bis), last line of code doesn't work : I get
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
What should I do to make it work? Yours sincerely Loïc