Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

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
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #pandas #dataframe #apply #function #multiple #arguments
ADD COMMENT
Topic
Name
5+6 =