Created
December 30, 2020 22:14
-
-
Save justinhchae/1402ab49e90d1f5ac0e36af4a6bb0bc2 to your computer and use it in GitHub Desktop.
A simple, do nothing lambdas function on a 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
# copy col2 value into a new column | |
col_new = str(col1 + '_new') | |
df[col_new] = df.apply(lambda x: x[col2] , axis=1) | |
print(df[[col1, col_new, col2]].head(2)) | |
# output | |
""" | |
event_date event_date_new received_date | |
2011-01-05 2011-01-31 2011-01-31 | |
2011-01-05 2011-01-31 2011-01-31 | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment