How to use join to fill missing values of a column - Python Pandas? -


to concrete, have 2 dataframes:

df1:

date    12/1/14 3 12/2/14 nan 12/3/14 2 12/2/14 nan 12/4/14 nan 12/6/14 5 

df2:

        b 12/2/14 20 12/4/14 30 

i want kind of left outer join fill missing values in df1, , generate

df3:

date    12/1/14 3 12/2/14 20 12/3/14 2 12/2/14 20 12/4/14 30 12/6/14 5 

any efficient way make it?

you can use combine_first (only columns names should match, therefore first rename column b in df2):

in [8]: df2 = df2.rename(columns={'b':'a'})  in [9]: df1.combine_first(df2) out[9]:           12/1/14   3 12/2/14  20 12/2/14  20 12/3/14   2 12/4/14  30 12/6/14   5 

Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -