I have the following two dataframes:
df:
value period 2000-01-01 100 2000-04-01 200 2000-07-01 300 2000-10-01 400 2001-01-01 500 df1:
value period 2000-07-01 350 2000-10-01 450 2001-01-01 550 2001-04-01 600 2001-07-01 700 This is the desired output:
df:
value period 2000-01-01 100 2000-04-01 200 2000-07-01 350 2000-10-01 450 2001-01-01 550 2001-04-01 600 2001-07-01 700 I have set_index(['period']) on both df1 and df2. I also tried few things including concat and where statement after creating new column but notting works as expected. My first dataframe is primary. The second is kind of update. It should replace the corresponding values in the first one and in the same time add new records if any available.
How I can do this?
pd.concat([df, df1], axis=0)