pandas apply multiple arguments code example
Example 1: multiple args for pandas apply
df["col_added"] = df.apply(lambda x: add_a_b(x["col_1"], x["col_2"]), axis = 1)
Example 2: pandas dataframe apply function with multiple arguments
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