Last active
May 21, 2021 03:41
-
-
Save kastnerp/3929010675f0dec5105a8e881e053732 to your computer and use it in GitHub Desktop.
Lambda function with pandas that takes two input which themselves are columns in the DataFrame
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
df = pd.DataFrame([[4, 9]] * 3, columns=['A', 'B']) | |
def do_stuff(x,y): | |
return x*y | |
df['new']= df.apply(lambda x: do_stuff(x['A'],x['B'] ), axis= 1) | |
print(df) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment