I have two dataframes; df1 and df2
df1 looks like this:
df2 looks like this:
My aim is to join df1 and df2 based on three keys: city, Year and Asset_Type as follows:
Index_step1=pd.merge( df1, df2[['city','Year','Asset_Type','psqm_city','city_returns']] , right_on =['city','Year', 'Asset_Type'], left_on=['city','Year','Asset_Type'], how = 'right')
My aim is to have the values of the Year 2021 appear in the output Index_step1 (2021 appear in df2 but not in df1). The right_join should keep the rows of the right dataframe (df2) but i am puzzled as to why the values of the Year 2021 do not appear in the output which looks like this (see below). I also tried outer join but the values of Year 2021 still do not appear there. Any idea what i am missing here? Thanks
Index_step1



Yeah looks like a bug and I'm gonna recommend a weird thing can you try to write left_on paramater first then right_on cause it seems like your function is doing left join not right join