Answers for "pandas dataframe apply function with multiple arguments"

0

multiple args for pandas apply

df["col_added"] = df.apply(lambda x: add_a_b(x["col_1"], x["col_2"]), axis = 1)
Posted by: Guest on May-10-2021
-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
Posted by: Guest on November-03-2020

Code answers related to "pandas dataframe apply function with multiple arguments"

Python Answers by Framework

Browse Popular Code Answers by Language