-
-
Save MuseHorizon/e5fa0dfad24c9a7aaa8ad153d05d4ea0 to your computer and use it in GitHub Desktop.
Pandas Index Match
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
# Add only 1 column (City) | |
table1_city=table1.merge(table2[['Person ID','City']],how='left',on='Person ID') | |
#Add all columns of table 2 (City and language) | |
table1_all=table1.merge(table2,how='left',on='Person ID') | |
#One liner to fill Nans | |
table1_fill_nans=table1.merge(table2[['Person ID','City']],how='left',on='Person ID').fillna('Unknown') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment