-1

where value of countyFIPS of df1 = value of FIPS of df2 merge the rows df1

countyFIPS  feb    march  
1001          aa    45
1002          bb     1    

df2

FIPS   dec    nov   
1001    ee    45
1002    gf     1 

I want the result show like

countyFIPS      feb    march   dec    nov 
    1001          aa    45       ee    45
    1002          bb     1       gf     1 

2 Answers2

1

df.merge(df2, left_on='countyFIPS', right_on='FIPS', how='inner').drop(columns=['FIPS']).

But before this I would like you to take a look at this post. This post already teaches everything required for merging.

Anurag Reddy
  • 1,159
  • 11
  • 19
1

Just use join as below:

df1.join(df2, how='left').drop(['FIPS'],axis=1)
Grayrigel
  • 3,474
  • 5
  • 14
  • 32