@kailash_negi wrote:
Hi,
I’ve two pandas dataframes and have to perform an outer join on these two dataframes but I am not getting desired results. So what I want is when I perform join, missing data in one dataframe should be filled by data in other dataframe if it exists and key matches. And if there are observations with new keys than they should be appended at the bottom of the output dataframe.
I’ve attached the screenshots here as to know how dataframes look like. I’m using below code for performing outer join but its not giving me desired result i.e. there is some information in second dataframe which is not getting populated in first dataframe (wherever it’s missing) after performing join.
ColNames = list(df_second.columns.difference(df_first.columns))
ColNames.append(‘EmpID’)
merged_df = pd.merge(df_first,df_second[ColNames],how=‘outer’,on=[‘EmpID’])I’ve also attached the output dataframe screenshot.
I’ll really appreciate if you guys can help me here.
Regards,
Kailash Negi
Posts: 1
Participants: 1