I have two dataframes that I want to combine to add col SLR from df2 to df1 based on the datetimeindex in df1 and the datetime column in df2. The code below works, but I keep getting an error that I need to fix
df1:
datetimeindex name val
2014-01-01 X 0.9
2014-02-01 Y 0.91
2014-03-01 Z 0.92
df2:
index datetime SLR
1 2013-10-01 1
2 2013-11-01 2
3 2013-12-01 3
I am trying to combine df2 with df1 by the datetime column in df2 and the datetimeindex in df1 with this:
df1['SLR'] = df1['date'].map(df2.set_index('date')['SLR'])
This works, but I keep getting this error:
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
dryhobfr['SLR'] = dryhobfr['date'].map(SLR.set_index('date')['SLR'])
<ipython-input-140-9fa4b21486e9>:17: SettingWithCopyWarning:
...
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
wethobfr['SLR'] = wethobfr['date'].map(SLR.set_index('date')['SLR'])