-1

I have two dataframes that are slightly different but have date as common and I would like to merge them into one with the left dframe as the columns:

Left Dataframe: enter image description here

Right dataframe: enter image description here

Join will be on date and the columns in the right dataframe description = instrument, close = close, the rest can be left out.

I would also like the right dataframe to have Nan where there are dates where there is no data for it.

Thanks Ed

user7346517
  • 25
  • 1
  • 6
  • Almost, I think I need to use concat but how do you concat two dataframes that have different column names or is it just simpler the change the column names so they are the same? – user7346517 Nov 24 '20 at 10:11

1 Answers1

0
df = left_df.merge(right_df, 
                   right_on=['date','description',' 'close'], 
                   left_on=['date','instrument','close'], 
                   how='left')

then drop what you dont want

Paul Brennan
  • 2,638
  • 4
  • 19
  • 26
  • Thanks but this just joins them it does not put the description in the instrument column and the close in the close column, I think I need concat. – user7346517 Nov 24 '20 at 10:10