I have a pandas data frame(df1) and I need to replace some of the df1 values with another data frame (df2). the df1 contains a time series from 1998-01-01 to 2002-12-31 and df1 contains time series from 1998-03-01 to 1998-07-31.
I want to replace the df1 values with df2 values for the time period of df2 (i.e. 1998-03-01 to 1998-07-31)
df1=
date kc
1998-01-01 0
1998-01-02 0
1998-01-03 0
1998-01-04 0
1998-01-05 0
.
.
.
2002-12-30 0
2002-12-31 0
and df2=
date kc
1998-03-01 0.3
1998-03-02 0.35
1998-03-03 0.4
1998-03-04 0.45
1998-03-05 0.4
.
.
.
1998-07-30 0.6
1998-07-31 0.7
Where the date column is set index for both of the dataframes. I tried the following:
df1.loc["1998-03-01":"1998-07-31","kc"]=df2
But it changes nothing, df1 remains same.