Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

pandas apply with multiple arguments

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