multiple args for pandas apply
df["col_added"] = df.apply(lambda x: add_a_b(x["col_1"], x["col_2"]), axis = 1)
multiple args for pandas apply
df["col_added"] = df.apply(lambda x: add_a_b(x["col_1"], x["col_2"]), axis = 1)
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
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us