Aplicar múltiples args para pandas
df["col_added"] = df.apply(lambda x: add_a_b(x["col_1"], x["col_2"]), axis = 1)
Cheerful Chimpanzee
df["col_added"] = df.apply(lambda x: add_a_b(x["col_1"], x["col_2"]), axis = 1)
def some_func(row, var1):
return str(row['A']) + '-' + str(row['B']) + '-' + var1
df['C'] = df.apply(some_func, var1='DOG', axis=1)
df
A B C
0 foo x foo-x-DOG
1 bar y bar-y-DOG
def some_func(row, var1):
return '{0}-{1}-{2}'.format(row['A'], row['B'], var1)
df['C'] = df.apply(some_func(row, var1='DOG'), axis=1)
df
A B C
0 foo x foo-x-DOG
1 bar y bar-y-DOG