I downloaded data from different sources in dataframes and would like to merge them in one final DataFrame. Let's illustarte it with the following example:
dataframe 1 (already multi indexed columns)
index stockA stockB ...
O L H C O L H C
1/1/19 10 15 20 17 35 30 39 37
2/1/19 ... ...
...
dataframe 2 (non multi indexed columns)
index stockA stockB
1/1/19 1.5 3.2
2/1/19 ... ...
...
I would like to merge both dataframe and giving a column name to data in dataframe2 . Index Date might be not the same in both dataframe, So i might need to do an inner merge.
Expected outputs (multi indexed columns)
index stockA stockB ...
O L H C new_col O L H C new_col
1/1/19 10 15 20 17 1.5 35 30 39 37 3.2
2/1/19 ... ...
...
1)and2)? Whyinner mergewith sample data is necessary? Maybe is necessary change data to minimal, complete, and verifiable example, especially for2)2)as I figured it out. I'd needinner mergebecause dates might not match between dataframes. But I can overcome this by reslicing the new dataframe with intersected dates between dataframes.